Skip to content

Raphtory


Raphtory

Test and Build Latest Release Issues Crates.io PyPI

🌍 Website   📒 API Documentation   Pometry   🧙🏻‍ Tutorial   🐛 Report a Bug   Join Slack


Raphtory is an in-memory graph tool 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, multilayer modelling, and advanced analytics beyond simple querying like community evolution, dynamic scoring, and mining temporal motifs.

Below you can see an example of these APIs and the sort of questions you can ask!

Graph

from raphtory import Graph
from raphtory import algorithms as algo
import pandas as pd

# Create a new graph
graph = Graph()

# Add some data to your graph
graph.add_node(timestamp=1, id="Alice")
graph.add_node(timestamp=1, id="Bob")
graph.add_node(timestamp=1, id="Charlie")
graph.add_edge(timestamp=2, src="Bob", dst="Charlie", properties={"weight": 5.0})
graph.add_edge(timestamp=3, src="Alice", dst="Bob", properties={"weight": 10.0})
graph.add_edge(timestamp=3, src="Bob", dst="Charlie", properties={"weight": -15.0})

# Check the number of unique nodes/edges in the graph and earliest/latest time seen.
print(graph)

results = [["earliest_time", "name", "out_degree", "in_degree"]]

# Collect some simple node metrics Ran across the history of your graph with a rolling window
for graph_view in graph.rolling(window=1):
    for v in graph_view.nodes:
        results.append(
            [graph_view.earliest_time, v.name, v.out_degree(), v.in_degree()]
        )

# Print the results
print(pd.DataFrame(results[1:], columns=results[0]))

# Grab an edge, explore the history of its 'weight'
cb_edge = graph.edge("Bob", "Charlie")
weight_history = cb_edge.properties.temporal.get("weight").items()
print(
    "The edge between Bob and Charlie has the following weight history:", weight_history
)

# Compare this weight between time 2 and time 3
weight_change = cb_edge.at(2)["weight"] - cb_edge.at(3)["weight"]
print(
    "The weight of the edge between Bob and Charlie has changed by",
    weight_change,
    "pts",
)

# Run pagerank and ask for the top ranked node
top_node = algo.pagerank(graph).top_k(1)
print(
    "The most important node in the graph is",
    top_node[0][0],
    "with a score of",
    top_node[0][1],
)

Output

Graph(number_of_nodes=3, number_of_edges=2, number_of_temporal_edges=3, earliest_time=1, latest_time=3)
   earliest_time     name  out_degree  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 most important node in the graph is Node(name=Charlie, earliest_time=1, latest_time=3) with a score of 0.4744116163405977

Excited to give it a go?

This site have been created to get new users of Raphtory up to speed by explaining the most important features via meaningful examples. You can get started straight away by heading to the User Guide. If you prefer learning via APIs and reading into specific object or functions, your best best it to visit the API documentation: Python | Rust.

Community

Join the growing community of open-source enthusiasts using Raphtory to power their graph analysis projects!

  • Follow Slack for the latest Raphtory news and development

  • Join our Slack to chat with us and get answers to your questions!

Haaroon ljeub-pometry miratepuffin iamsmkr fabianmurariu rachchan ricopinazo narnolddd jamesalford dependabot[bot] github-actions[bot] Alnaimi- rutujasurve94 louisch Pometry-Team lejohnyjohn nrs1729 Dullaz D4rkisek HelleKev jatindersangha LJeub Peijie-Zhong haoxins aw4309 felixcdr

Sponsors

Contribute

The best way to start contributing is to give Raphtory a ⭐ on github! Once you have done that, if you want to raise an issue, submit a PR or give us some feedback, you can checkout our Contributing Guide, the open list of issues, or hit us up directly on slack.

License

Raphtory is licensed under the terms of the GNU General Public License v3.0.