networkx.algorithms.is_connected

networkx.algorithms.is_connected(G)[source]

Return True if the graph is connected, false otherwise.

Parameters:

G : NetworkX Graph

An undirected graph.

Returns:

connected : bool

True if the graph is connected, false otherwise.

Raises:

NetworkXNotImplemented:

If G is undirected.

Notes

For undirected graphs only.

Examples

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