NetworkX

Previous topic

networkx.LabeledGraph.has_edge

Next topic

networkx.LabeledGraph.nodes_with_selfloops

Quick search

networkx.LabeledGraph.has_neighbor

LabeledGraph.has_neighbor(u, v)

Return True if node u has neighbor v.

This returns True if there exists any edge (u,v,data) for some data.

See also

has_edge

Examples

>>> G=nx.path_graph(4)
>>> G.has_neighbor(0,1)
True
>>> G.has_edge(0,1) # same as has_neighbor
True
>>> 1 in G[0]  # this gives KeyError if u not in G
True