# connected_component_subgraphs¶

connected_component_subgraphs(G, copy=True)[source]

Generate connected components as subgraphs.

Parameters: G (NetworkX graph) – An undirected graph. copy (bool (default=True)) – If True make a copy of the graph attributes comp – A generator of graphs, one for each connected component of G. generator NetworkXNotImplemented: – If G is undirected.

Examples

>>> G = nx.path_graph(4)

>>> Gc = max(nx.connected_component_subgraphs(G), key=len)