This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.
Generate connected components as subgraphs.
G : NetworkX graph
An undirected graph.
copy: bool (default=True)
If True make a copy of the graph attributes
comp : generator
A generator of graphs, one for each connected component of G.
For undirected graphs only. Graph, node, and edge attributes are copied to the subgraphs by default.
>>> G = nx.path_graph(4) >>> G.add_edge(5,6) >>> graphs = list(nx.connected_component_subgraphs(G))