Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

number_connected_components

number_connected_components(G)[source]

Return the number of connected components.

Parameters:

G : NetworkX graph

An undirected graph.

Returns:

n : integer

Number of connected components

Notes

For undirected graphs only.