NetworkX

Previous topic

networkx.connected_components

Next topic

networkx.node_connected_component

networkx.connected_component_subgraphs

connected_component_subgraphs(G)

Return a list of graphs of each connected component of G.

The list is ordered from largest connected component to smallest. For undirected graphs only.

Examples

Get largest connected component

>>> G=nx.path_graph(4)
>>> G.add_edge(5,6)
>>> H=nx.connected_component_subgraphs(G)[0]