This documents the development version of NetworkX. Documentation for the current release can be found here.
Graph adjacency object holding the neighbors of each node.
This object is a read-only dict-like structure with node keys and neighbor-dict values. The neighbor-dict is keyed by neighbor to the edgekey-data-dict. So
G.adj['color'] = 'blue'sets the color of the edge
(3, 2, 0)to
Iterating over G.adj behaves like a dict. Useful idioms include
for nbr, nbrdict in G.adj[n].items():.
The neighbor information is also provided by subscripting the graph. So
for nbr, foovalue in G[node].data('foo', default=1):works.
For directed graphs,
G.adjholds outgoing (successor) info.