NetworkX

Previous topic

networkx.DiGraph.add_node

Next topic

networkx.DiGraph.remove_node

Quick search

networkx.DiGraph.add_nodes_from

DiGraph.add_nodes_from(nbunch)

Add nodes from nbunch.

Parameters:

nbunch : list, iterable

A container of nodes that will be iterated through once (thus it should be an iterator or be iterable). Each element of the container should be a valid node type: any hashable type except None.

Examples

>>> G=nx.DiGraph()
>>> G.add_nodes_from('Hello')
>>> K3=nx.complete_graph(3)
>>> G.add_nodes_from(K3)
>>> sorted(G.nodes())
[0, 1, 2, 'H', 'e', 'l', 'o']