Note

This documents the development version of NetworkX. Documentation for the current release can be found here.

networkx.DiGraph.adjacency

DiGraph.adjacency()

Returns an iterator over (node, adjacency dict) tuples for all nodes.

For directed graphs, only outgoing neighbors/adjacencies are included.

Returns

adj_iter – An iterator over (node, adjacency dictionary) for all nodes in the graph.

Return type

iterator

Examples

>>> G = nx.path_graph(4)  # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> [(n, nbrdict) for n, nbrdict in G.adjacency()]
[(0, {1: {}}), (1, {0: {}, 2: {}}), (2, {1: {}, 3: {}}), (3, {2: {}})]