dynetx.DynDiGraph.time_slice¶
-
DynDiGraph.
time_slice
(t_from, t_to=None)¶ Return an new graph containing nodes and interactions present in [t_from, t_to].
Parameters: - t_from (snapshot id, mandatory) –
- t_to (snapshot id, optional (default=None)) – If None t_to will be set equal to t_from
Returns: H – the graph described by interactions in [t_from, t_to]
Return type: a DynDiGraph object
Examples
>>> import dynetx as dn >>> G = dn.DynDiGraph() >>> G.add_interaction(0,1, t=0) >>> G.add_interaction(1,2, t=0) >>> G.add_interaction(2,3, 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) >>> H.interactions() [(0, 1), (1, 2), (1, 3)] >>> H = G.time_slice(0, 1) >>> H.interactions() [(0, 1), (1, 2), (1, 3), (0, 4), (4, 5), (5, 6)]