When using time_slice to create a time slice of a graph, the returned time slice contains wrong timestamps for the end of an interaction (which are always one unit to small) and the time slice does not take all interactions into account for directed graphs and reverses the direction of edges (see #135).
The terminology here was a bit confusing to me: when using time_slice(t_from=0, t_to=2), I expect the graph to include all snapshots from t=0 to and includingt=2. When adding an interaction add_interaction(t=0, e=2), I expect the interaction to last from t=0 to t=1 and vanish at e=2. (I hope I interpret the terminology used by the library correctly).
The changes in this branch therefore add an additional time unit when creating the time slice to take this into account.
The changes also respect the direction of edges for directed graphs when checking for seen nodes and when creating a list of interactions.
This should fix #135.
Example
G = dn.DynDiGraph()
G.add_interaction(0,1, t=0, e=2)
G.add_interaction(1,2, t=0)
G.add_interaction(2,4, t=0)
G.add_interaction(0,4, t=1)
G.add_interaction(4,5, t=1)
G.add_interaction(5,6, t=1)
G.add_interaction(7,1, t=2)
G.add_interaction(1,2, t=2)
G.add_interaction(2,3, t=2)
H = G.time_slice(0)
I = G.time_slice(0, 2)
Problem description
When using
time_slice
to create a time slice of a graph, the returned time slice contains wrong timestamps for the end of an interaction (which are always one unit to small) and the time slice does not take all interactions into account for directed graphs and reverses the direction of edges (see #135).The terminology here was a bit confusing to me: when using
time_slice(t_from=0, t_to=2)
, I expect the graph to include all snapshots fromt=0
to and includingt=2
. When adding an interactionadd_interaction(t=0, e=2)
, I expect the interaction to last fromt=0
tot=1
and vanish ate=2
. (I hope I interpret the terminology used by the library correctly).The changes in this branch therefore add an additional time unit when creating the time slice to take this into account.
The changes also respect the direction of edges for directed graphs when checking for
seen
nodes and when creating a list of interactions.This should fix #135.
Example
Previous behavior:
Behavior after changes: