

def connected_components(G):
    'Return nodes in connected components of graph.\n\n    Parameters\n    ----------\n    G : NetworkX Graph\n       An undirected graph.\n\n    Returns\n    -------\n    comp : list of lists\n       A list of nodes for each component of G.\n\n    See Also       \n    --------\n    strongly_connected_components\n\n    Notes\n    -----\n    The list is ordered from largest connected component to smallest.\n    For undirected graphs only. \n    '
    if G.is_directed():
        raise nx.NetworkXError('Not allowed for directed graph G.\n              Use UG=G.to_undirected() to create an undirected graph.')
    seen = {
        
    }
    components = []
    for v in G:
        if (v not in seen):
            c = nx.single_source_shortest_path_length(G, v)
            components.append(list(c.keys()))
            v.update(c)
    components.sort(key=len, reverse=True)
    return components

dataset/ETHPy150Open gkno/gkno_launcher/src/networkx/algorithms/components/connected.py connected_components/VarMisuse@84/296 `seen`->`v`