DiGraph.__getitem__

DiGraph.__getitem__(n)

Returns a dict of neighbors of node n. Use: ‘G[n]’.

Parameters
nnode

A node in the graph.

Returns
adj_dictdictionary

The adjacency dictionary for nodes connected to n.

Notes

G[n] is the same as G.adj[n] and similar to G.neighbors(n) (which is an iterator over G.adj[n])

Examples

>>> G = nx.path_graph(4)  # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> G[0]
AtlasView({1: {}})