NetworkX

Previous topic

networkx.MultiDiGraph.adjacency_list

Next topic

networkx.MultiDiGraph.nbunch_iter

Quick search

networkx.MultiDiGraph.adjacency_iter

MultiDiGraph.adjacency_iter()

Return an iterator of (node, adjacency dict) tuples for all nodes.

This is the fastest way to look at every edge. For directed graphs, only outgoing adjacencies are included.

Notes

The dictionary returned is part of the internal graph data structure; changing it could corrupt that structure. This is meant for fast inspection, not mutation.

For MultiGraph/MultiDiGraph multigraphs, a list of edge data is the value in the dict.

Examples

>>> G=nx.path_graph(4)
>>> [(n,nbrdict) for n,nbrdict in G.adjacency_iter()]
[(0, {1: 1}), (1, {0: 1, 2: 1}), (2, {1: 1, 3: 1}), (3, {2: 1})]