Return an iterator over the nodes.
Parameters: | data : boolean, optional (default=False)
|
---|---|
Returns: | niter : 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])
>>> for n in G:
... print n,
0 1 2
Examples
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> G.add_path([0,1,2])
>>> for n in G.nodes_iter():
... print n,
0 1 2
>>> for n,d in G.nodes_iter(data=True):
... print d,
{} {} {}