Note

This documents the development version of NetworkX. Documentation for the current release can be found here.

networkx.algorithms.components.number_connected_components

number_connected_components(G)[source]

Returns the number of connected components.

Parameters
GNetworkX graph

An undirected graph.

Returns
ninteger

Number of connected components

Notes

For undirected graphs only.