G-DynaDist · Chapter 1

Quick start

Compute the distance between two temporal graphs in a few lines of code.

This is a minimal example to introduce the main functions, meant to be copied and adapted. All inputs and parameters are discussed in depth in the User guide.

Installation

pip install gdynadist

Basic use

Temporal graphs are represented as pandas dataframes of temporal edges with columns i, j, t (see the supported formats).

import pandas as pd
from GDynaDist import Graphs4Distance

# load the two temporal graphs to compare
df1 = pd.read_csv('df1.csv')
df2 = pd.read_csv('df2.csv')

# initialize the Data class
Data = Graphs4Distance()

# add the two graphs to the Data class and give them a name
Data.LoadDataset(df1, 'first_graph')
Data.LoadDataset(df2, 'second_graph')

# compute the distance between the two graphs
unmatched_distance = Data.GetDistance('first_graph', 'second_graph', distance_type = 'unmatched')

To compute the matched distance, you must specify the known bijective mapping between the nodes of the two graphs as a dictionary. If the two graphs use the same node labels, simply write

matched_distance = Data.GetDistance('first_graph', 'second_graph', distance_type = 'matched', node_mapping = 'Same')
Note

Graphs4Distance and LoadDataset have several parameters that can be tuned to speed up the computation and reduce memory usage. See the User guide for all of them.

Important

A distance is an absolute measure of similarity, not a relative one. When using it for temporal graph analysis, always compare it with a baseline (for instance, a null model) to understand whether two graphs are more or less similar than expected. See the Experiments for examples.