dynetx.classes.function.time_slice

dynetx.classes.function.time_slice(G, t_from, t_to=None)

Return an iterator for (node, degree) at time t.

The node degree is the number of edges adjacent to the node.

Parameters:
  • G (graph) – A DyNetx graph.
  • 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 DynGraph object

Examples

>>> G = dn.DynGraph()
>>> G.add_path([0,1,2,3], t=0)
>>> G.add_path([0,4,5,6], t=1)
>>> G.add_path([7,1,2,3], t=2)
>>> H = dn.time_slice(G, 0)
>>> H.edges()
[(0, 1), (1, 2), (1, 3)]
>>> H = dn.time_slice(G, 0, 1)
>>> H.edges()
[(0, 1), (1, 2), (1, 3), (0, 4), (4, 5), (5, 6)]