NetworkX

Previous topic

networkx.Graph.get_edge

Next topic

networkx.Graph.neighbors_iter

Quick search

networkx.Graph.neighbors

Graph.neighbors(n)

Return a list of the nodes connected to the node n.

Notes

It is sometimes more convenient (and faster) to access the adjacency dictionary as G[n]

>>> G=nx.Graph()
>>> G.add_edge('a','b','data')
>>> G['a']
{'b': 'data'}

Examples

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