- common_neighbors(G, u, v)¶
Returns the common neighbors of two nodes in a graph.
A NetworkX undirected graph.
- u, vnodes
Nodes in the graph.
Iterator of common neighbors of u and v in the graph.
If u or v is not a node in the graph.
>>> G = nx.complete_graph(5) >>> sorted(nx.common_neighbors(G, 0, 1)) [2, 3, 4]