yields True if the graph g is connected, and False otherwise.


  • ConnectedGraphQ works for any graph object.
  • A graph is connected if there is a path between every pair of vertices.


open allclose all

Basic Examples  (2)

Test whether a graph is connected:

A graph with isolated vertices is not connected:

Scope  (6)

Test undirected graphs:

Directed graphs:


Mixed graphs:

ConnectedGraphQ gives False for anything that is not a connected graph:

ConnectedGraphQ works with large graphs:

Applications  (1)

Compute the probability that the WattsStrogatz random graph model is connected:

Properties & Relations  (5)

The graph distance matrix of a connected graph does not have entries:

Connected graph:

Disconnected graph:

The minimum number of edges in a connected graph with vertices is :

A path graph with vertices has exactly edges:

The sum of the vertex degrees of a connected graph is greater than for the underlying simple graph:

A disconnected graph:

An undirected tree is connected:

An undirected path is connected:

Wolfram Research (2010), ConnectedGraphQ, Wolfram Language function,


Wolfram Research (2010), ConnectedGraphQ, Wolfram Language function,


Wolfram Language. 2010. "ConnectedGraphQ." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2010). ConnectedGraphQ. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_connectedgraphq, author="Wolfram Research", title="{ConnectedGraphQ}", year="2010", howpublished="\url{}", note=[Accessed: 23-June-2024 ]}


@online{reference.wolfram_2024_connectedgraphq, organization={Wolfram Research}, title={ConnectedGraphQ}, year={2010}, url={}, note=[Accessed: 23-June-2024 ]}