def connected_component_subgraphs(G):
    cc=connected_components(G)
    graph_list=[]
    for c in cc:
        graph_list.append(G.subgraph(c).copy())
    return graph_list
Return connected components as subgraphs.
dataset/ETHPy150Open gkno/gkno_launcher/src/networkx/algorithms/components/connected.py/connected_component_subgraphs