How to construct a temporal network using python
Here is a way to do what you want. First, load your data into a pandas dataframe using pd.read_fwf
(I saved your data in a file called data_net.txt
).
Then incrementally add edges to your temporal network using pp.add_edge
. Run t
in a cell to see the animation.
See code below for more details:
import networkx as nx
import matplotlib.pyplot as plt
import pandas as pd
import pathpy as pp
df=pd.read_fwf('data_net.txt')
t = pp.TemporalNetwork()
[t.add_edge(df['Station_start'][i],df['Station_end'][i],int(df['Day'][i])) for i in range(len(df))]
t # run t in a cell to start the animation
Below is what this code returns. Based on the link you gave, you can also control the speed of the animation by styling the network with pathpy.