nodes_iter¶
-
MultiGraph.
nodes_iter
(data=False)¶ Return an iterator over the nodes.
Parameters: data (boolean, optional (default=False)) – If False the iterator returns nodes. If True return a two-tuple of node and node data dictionary Returns: niter – An iterator over nodes. If data=True the iterator gives two-tuples containing (node, node data, dictionary) Return type: iterator Notes
If the node data is not required it is simpler and equivalent to use the expression ‘for n in G’.
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G.add_path([0,1,2])
Examples
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G.add_path([0,1,2])
>>> [d for n,d in G.nodes_iter(data=True)] [{}, {}, {}]