Note
This documents the development version of NetworkX. Documentation for the current release can be found here.
Graph.
__iter__
Iterate over the nodes. Use: ‘for n in G’.
niter – An iterator over all nodes in the graph.
iterator
Examples
>>> G = nx.path_graph(4) # or DiGraph, MultiGraph, MultiDiGraph, etc >>> [n for n in G] [0, 1, 2, 3] >>> list(G) [0, 1, 2, 3]