DynGraph.add_interaction(u, v, t=None, e=None)

Add an interaction between u and v at time t vanishing (optional) at time e.

The nodes u and v will be automatically added if they are not already in the graph.

  • v (u,) – Nodes can be, for example, strings or numbers. Nodes must be hashable (and not None) Python objects.
  • t (appearance snapshot id, mandatory) –
  • e (vanishing snapshot id, optional (default=None)) –

See also

add a collection of interaction at time t


Adding an interaction that already exists but with different snapshot id updates the interaction data.


The following all add the interaction e=(1,2, 0) to graph G: >>> import dynetx as dn >>> G = dn.DynGraph() >>> G.add_interaction(1, 2, 0) # explicit two-node form >>> G.add_interaction( [(1,2)], t=0 ) # add interaction from iterable container

Specify the vanishing of the interaction

>>>> G.add_interaction(1, 3, t=1, e=10)

will produce an interaction present in snapshots [0, 9]