Skip to content

Running algorithms

Within Raphtory we have implemented many of the standard algorithms you may expect within a graph library, but have also added several temporal algorithms such as Temporal Reachability and Temporal Motifs. You can check out the full list of available algorithms here and edit the code snippets below in your own notebook to test them out.

Before we look at the different types of algorithms, let's first load in some data. For these examples we are going to use the One graph to rule them all dataset, which maps the co-occurrence of characters within the Lord of The Rings books. This dataset is a simple edge list, consisting of the source character, destination character and the sentence they occurred together in (which we shall use as a timestamp). The dataframe for this can be seen in the output below.

Graph

from raphtory import Graph
import pandas as pd

df = pd.read_csv("data/lotr.csv")
print(df)

lotr_graph = Graph.load_from_pandas(
    edge_df=df, edge_src="src", edge_dst="dst", edge_time="time"
)

Output

            src        dst   time
0       Gandalf     Elrond     33
1         Frodo      Bilbo    114
2        Blanco     Marcho    146
3         Frodo      Bilbo    205
4        Thorin    Gandalf    270
...         ...        ...    ...
2644      Merry  Galadriel  32666
2645      Merry        Sam  32666
2646  Galadriel        Sam  32666
2647     Pippin      Merry  32671
2648     Pippin      Merry  32674

[2649 rows x 3 columns]