NetworkX

Previous topic

networkx.LabeledGraph.neighbors_iter

Next topic

networkx.LabeledGraph.adjacency_list

Quick search

networkx.LabeledGraph.__getitem__

LabeledGraph.__getitem__(n)

Return the neighbors of node n. Use “G[n]”.

Notes

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

G[u][v] returns the edge data for edge (u,v).

>>> G=nx.path_graph(4)
>>> print G[0][1]
1

Assigning G[u][v] may corrupt the graph data structure.

Examples

>>> G=nx.path_graph(4)
>>> print G[0]
{1: 1}