NetworkX

Previous topic

networkx.DiGraph.nodes

Next topic

networkx.DiGraph.__iter__

Quick search

networkx.DiGraph.nodes_iter

DiGraph.nodes_iter()

Return an iterator for the nodes.

Notes

It is simpler and equivalent to use the expression “for n in G”

>>> G=nx.path_graph(3)
>>> for n in G:
...     print n,
0 1 2

Examples

>>> G=nx.path_graph(3)
>>> for n in G.nodes_iter():
...     print n,
0 1 2

You can also say

>>> G=nx.path_graph(3)
>>> for n in G:
...     print n,
0 1 2