@not_implemented_for('directed')
def common_neighbors(G, u, v):
    if u not in G:
        raise nx.NetworkXError('u is not in the graph.')
    if v not in G:
        raise nx.NetworkXError('v is not in the graph.')

    # Return a generator explicitly instead of yielding so that the above
    # checks are executed eagerly.
    return (w for w in G[u] if w in G[v] and w not in (u, v))
Return the common neighbors of two nodes in a graph.
dataset/ETHPy150Open networkx/networkx/networkx/classes/function.py/common_neighbors