are_neighbors(G, u, v)¶
Returns true if u is adjacent to v. Otherwise, returns false.
- G (NetworkX graph) – An undirected graph.
- u (node) – A node in the graph.
- v (node) – A node in the graph.
True if u is a neighbor of v in G, False otherwise.
>>> G = nx.star_graph(3) # Star on 4 nodes >>> nx.are_neighbors(G, 0, 1) True >>> nx.are_neighbors(G, 1, 2) False