dynetx.DynGraph.add_interaction

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.

Parameters

u, vnodes

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_edges_from : add a collection of interaction at time t

Notes

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

Examples

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]