π Website
 
π Documentation
 
Pometry
 
π§π»β Tutorial
 
π Report a Bug
 
Join Slack
Raphtory is an in-memory vectorised graph database written in Rust with friendly Python APIs on top. It is blazingly fast, scales to hundreds of millions of edges
on your laptop, and can be dropped into your existing pipelines with a simple pip install raphtory
.
It supports time traveling, full-text search, multilayer modelling, and advanced analytics beyond simple querying like automatic risk detection, dynamic scoring, and temporal motifs.
If you wish to contribute, check out the open list of issues, bounty board or hit us up directly on slack. Successful contributions will be reward with swizzling swag!
```python from raphtory import Graph from raphtory import algorithms as algo import pandas as pd
graph = Graph()
graph.addvertex(timestamp=1, id="Alice") graph.addvertex(timestamp=1, id="Bob") graph.addvertex(timestamp=1, id="Charlie") graph.addedge (timestamp=2, src="Bob", dst="Charlie", properties={"weight":5.0}) graph.addedge (timestamp=3, src="Alice", dst="Bob", properties={"weight":10.0}) graph.addedge (timestamp=3, src="Bob", dst="Charlie", properties={"weight":-15.0})
print(graph)
results = [["earliesttime", "name", "outdegree", "in_degree"]]
for graphview in graph.rolling(window=1): for v in graphview.vertices(): results.append([graphview.earliesttime(), v.name(), v.outdegree(), v.indegree()])
print(pd.DataFrame(results[1:], columns=results[0]))
cbedge = graph.edge("Bob","Charlie") weighthistory = cbedge.properties.temporal.get("weight").items() print("The edge between Bob and Charlie has the following weight history:", weighthistory)
weightchange = cbedge.at(2)["weight"] - cbedge.at(3)["weight"] print("The weight of the edge between Bob and Charlie has changed by",weightchange,"pts")
topnode = algo.pagerank(graph).topk(1) print("The most important node in the graph is",topnode[0][0],"with a score of",topnode[0][1]) ```
```a Graph(numberofedges=2, numberofvertices=3, earliesttime=1, latesttime=3)
| | earliesttime | name | outdegree | in_degree | |---|---------------|---------|------------|-----------| | 0 | 1 | Alice | 0 | 0 | | 1 | 1 | Bob | 0 | 0 | | 2 | 1 | Charlie | 0 | 0 | | 3 | 2 | Bob | 1 | 0 | | 4 | 2 | Charlie | 0 | 1 | | 5 | 3 | Alice | 1 | 0 | | 6 | 3 | Bob | 1 | 1 | | 7 | 3 | Charlie | 0 | 1 |
The edge between Bob and Charlie has the following weight history: [(2, 5.0), (3, -15.0)]
The weight of the edge between Bob and Charlie has changed by 20.0 pts
The top node in the graph is Charlie with a score of 0.4744116163405977 ```
Save a raphtory graph and set the GRAPH_DIRECTORY
environment variable to point to the directory containing the graph.
```bash mkdir -p /tmp/graphs mkdir -p examples/rust/src/bin/lotr/data/ tail -n +2 resource/lotr.csv > examples/rust/src/bin/lotr/data/lotr.csv
cd examples/rust && cargo run --bin lotr -r
cp examples/rust/src/bin/lotr/data/graphdb.bincode /tmp/graphs/lotr.bincode ```
The code below will run GraphQL with a UI at localhost:1736
GraphlQL will look for graph files in /tmp/graphs
or in the path set in the GRAPH_DIRECTORY
Environment variable.
bash
cd raphtory-graphql && cargo run -r
βΉοΈWarning: Server must have the same version + environment
The GraphQL server must be running in the same environment (i.e. debug or release) and same Raphtory version as the generated graph, otherwise it will throw errors due to incompatible graph metadata across versions.
Following will be output upon a successful launch
``bash
warning:
raphtory(lib) generated 17 warnings (run
cargo fix --lib -p raphtoryto apply 13 suggestions)
Finished release [optimized] target(s) in 0.91s
Running
Raphtory/target/release/raphtory-graphql`
loading graph from /tmp/graphs/lotr.bincode
Playground: http://localhost:1736
2023-08-11T14:36:52.444203Z INFO poem::server: listening, addr: socket://0.0.0.0:1736
at /Users/pometry/.cargo/registry/src/github.com-1ecc6299db9ec823/poem-1.3.56/src/server.rs:109
2023-08-11T14:36:52.444257Z INFO poem::server: server started at /Users/pometry/.cargo/registry/src/github.com-1ecc6299db9ec823/poem-1.3.56/src/server.rs:111 ```
Go to the Playground at http://localhost:1736
and execute the following commands:
Query:
bash
query GetNodes($graphName: String!) {
graph(name: $graphName) {
nodes {
name
}
}
}
Query Variables:
bash
{
"graphName": "lotr.bincode"
}
Expected Result:
bash
{
"data": {
"graph": {
"nodes": [
{
"name": "Gandalf"
},
{
"name": "Elrond"
},
{
"name": "Frodo"
},
{
"name": "Bilbo"
},
...
Raphtory is available for Python and Rust as of version 0.3.0. You should have Python version 3.10 or higher and it's a good idea to use conda, virtualenv, or pyenv.
bash
pip install raphtory
Check out Raphtory in action with our interactive Jupyter Notebook! Just click the badge below to launch a Raphtory sandbox online, no installation needed.
Want to give Raphtory a go on your laptop? You can checkout out the latest documentation and complete list of available algorithms or hop on our notebook based tutorials below!
| Type | Description | |----------|------------------------------------------------------------------------------------------| | Tutorial | Building your first graph |
| Type | Description | | ------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------| | Notebook | Use our powerful time APIs to find pump and dump scams in popular NFTs |
We host a page which triggers and saves the result of two benchmarks upon every push to the master branch.
View this here https://pometry.github.io/Raphtory/dev/bench/
Raphtory is currently offering rewards for contributions, such as new features or algorithms. Contributors will receive swag and prizes!
To get started, check out our list of desired algorithms at https://github.com/Raphtory/Raphtory/discussions/categories/bounty-board which include some low hanging fruit (π) that are easy to implement.
Join the growing community of open-source enthusiasts using Raphtory to power their graph analysis projects!
Want to get involved? Please join the Raphtory Slack group and speak with us on how you could pitch in!
Raphtory is licensed under the terms of the GNU General Public License v3.0 (check out our LICENSE file).