Adjust time_slice method to return sliced graph with correct interactions #159
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: