Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

__getitem__

MultiGraph.__getitem__(n)

Return a dict of neighbors of node n. Use the expression ‘G[n]’.

Parameters:

n : node

A node in the graph.

Returns:

adj_dict : dictionary

The adjacency dictionary for nodes connected to n.

Notes

G[n] is similar to G.neighbors(n) but the internal data dictionary is returned instead of a list.

Assigning G[n] will corrupt the internal graph data structure. Use G[n] for reading data only.

Examples

>>> G = nx.Graph()   # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> G.add_path([0,1,2,3])
>>> G[0]
{1: {}}