NetworkX

Previous topic

number_connected_components

Next topic

connected_component_subgraphs

connected_components

connected_components(G)[source]

Return nodes in connected components of graph.

Parameters :

G : NetworkX Graph

An undirected graph.

Returns :

comp : list of lists

A list of nodes for each component of G.

See also

strongly_connected_components

Notes

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