Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

networkx.MultiGraph.__iter__

MultiGraph.__iter__()

Iterate over the nodes. Use: ‘for n in G’.

Returns:niter – An iterator over all nodes in the graph.
Return type: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]