Warning

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

networkx.algorithms.components.is_connected

is_connected(G)[source]

Return True if the graph is connected, false otherwise.

Parameters:G (NetworkX Graph) – An undirected graph.
Returns:connected – True if the graph is connected, false otherwise.
Return type:bool
Raises:NetworkXNotImplemented: – If G is undirected.

Examples

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

Notes

For undirected graphs only.