dynetworkx.SnapshotGraph.add_nodes_from

SnapshotGraph.add_nodes_from(nbunch, sbunch=None, **attrs)

Adds nodes to snapshots in sbunch.

Parameters:
  • nbunch (container of nodes) – Each node in the nbunch list will be added to all graphs indexed in sbunch.
  • sbunch (container of snapshot indexes, optional (default= None)) – Each snapshot index in this list will be included in the returned list of node degrees. It is highly recommended that this list is sequential, however it can be out of order.
Returns:

Return type:

None

Examples

>>> G = dnx.SnapshotGraph()
>>> G.add_snapshot([(1, 2), (1, 3)])
>>> G.add_snapshot([(1, 4), (1, 3)])
>>> G.add_nodes_from([5, 6, 7], [0])
>>> G.add_nodes_from([8, 9, 10, 11], [1])
>>> nx.adjacency_matrix(G.get()[0]).todense()
[[0 1 1 0 0 0]
 [1 0 0 0 0 0]
 [1 0 0 0 0 0]
 [0 0 0 0 0 0]
 [0 0 0 0 0 0]
 [0 0 0 0 0 0]]
>>> nx.adjacency_matrix(G.get()[1]).todense()
[[0 1 1 0 0 0 0]
 [1 0 0 0 0 0 0]
 [1 0 0 0 0 0 0]
 [0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0]]