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