ConnectedGraphQ
Details
- ConnectedGraphQ works for any graph object.
- A graph is connected if there is a path between every pair of vertices.
Examples
open all close allBasic Examples (2)
Scope (6)
ConnectedGraphQ[[image]]ConnectedGraphQ[[image]]ConnectedGraphQ[[image]]ConnectedGraphQ[[image]]ConnectedGraphQ gives False for anything that is not a connected graph:
ConnectedGraphQ[x]ConnectedGraphQ works with large graphs:
g = GridGraph[{10, 10, 10, 10}];Timing[ConnectedGraphQ[g]]Applications (1)
Properties & Relations (5)
The graph distance matrix of a connected graph does not have
entries:
g = CycleGraph[3]GraphDistanceMatrix[g]//MatrixFormg = Graph[{12, 34}]GraphDistanceMatrix[g]//MatrixFormThe minimum number of edges in a connected graph with
vertices is
:
PetersenGraph[5, 2]{ConnectedGraphQ[%], EdgeCount[%] ≥ VertexCount[%] - 1}A path graph with
vertices has exactly
edges:
PathGraph[Range[10]]{ConnectedGraphQ[%], EdgeCount[%] ≥ VertexCount[%] - 1}The sum of the vertex degrees of a connected graph is greater than
for the underlying simple graph:
g = WheelGraph[4]{ConnectedGraphQ[g], Total[VertexDegree[g]] ≥ (VertexCount[g] - 1) / 2}g = Graph[Range[10], {12}]{ConnectedGraphQ[g], Total[VertexDegree[g]] ≥ (VertexCount[g] - 1) / 2}An undirected tree is connected:
TreeGraph[{12, 13, 14}]{TreeGraphQ[%], ConnectedGraphQ[%]}An undirected path is connected:
PathGraph[Range[10]]{PathGraphQ[%], ConnectedGraphQ[%]}History
Text
Wolfram Research (2010), ConnectedGraphQ, Wolfram Language function, https://reference.wolfram.com/language/ref/ConnectedGraphQ.html.
CMS
Wolfram Language. 2010. "ConnectedGraphQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ConnectedGraphQ.html.
APA
Wolfram Language. (2010). ConnectedGraphQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ConnectedGraphQ.html
BibTeX
@misc{reference.wolfram_2026_connectedgraphq, author="Wolfram Research", title="{ConnectedGraphQ}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/ConnectedGraphQ.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_connectedgraphq, organization={Wolfram Research}, title={ConnectedGraphQ}, year={2010}, url={https://reference.wolfram.com/language/ref/ConnectedGraphQ.html}, note=[Accessed: 12-June-2026]}