Note

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

networkx.algorithms.components.is_connected

is_connected(G)[source]

Returns True if the graph is connected, False otherwise.

Parameters
GNetworkX Graph

An undirected graph.

Returns
connectedbool

True if the graph is connected, false otherwise.

Raises
NetworkXNotImplemented

If G is directed.

Notes

For undirected graphs only.

Examples

>>> G = nx.path_graph(4)
>>> print(nx.is_connected(G))
True