WOLFRAM

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

Details

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

Examples

open allclose all

Basic Examples  (2)Summary of the most common use cases

Test whether a graph is connected:

Out[1]=1
Out[2]=2

A graph with isolated vertices is not connected:

Out[1]=1
Out[2]=2

Scope  (6)Survey of the scope of standard use cases

Test undirected graphs:

Out[1]=1

Directed graphs:

Out[1]=1

Multigraphs:

Out[1]=1

Mixed graphs:

Out[1]=1

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

Out[1]=1

ConnectedGraphQ works with large graphs:

Out[2]=2

Applications  (1)Sample problems that can be solved with this function

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

Out[3]=3

Properties & Relations  (5)Properties of the function, and connections to other functions

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

Out[1]=1

Connected graph:

Disconnected graph:

Out[3]=3

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

Out[1]=1
Out[2]=2

A path graph with vertices has exactly edges:

Out[3]=3
Out[4]=4

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

Out[1]=1
Out[2]=2

A disconnected graph:

Out[3]=3
Out[4]=4

An undirected tree is connected:

Out[1]=1
Out[2]=2

An undirected path is connected:

Out[1]=1
Out[2]=2
Wolfram Research (2010), ConnectedGraphQ, Wolfram Language function, https://reference.wolfram.com/language/ref/ConnectedGraphQ.html.
Wolfram Research (2010), ConnectedGraphQ, Wolfram Language function, https://reference.wolfram.com/language/ref/ConnectedGraphQ.html.

Text

Wolfram Research (2010), ConnectedGraphQ, Wolfram Language function, https://reference.wolfram.com/language/ref/ConnectedGraphQ.html.

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.

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

Wolfram Language. (2010). ConnectedGraphQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ConnectedGraphQ.html

BibTeX

@misc{reference.wolfram_2025_connectedgraphq, author="Wolfram Research", title="{ConnectedGraphQ}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/ConnectedGraphQ.html}", note=[Accessed: 29-May-2025 ]}

@misc{reference.wolfram_2025_connectedgraphq, author="Wolfram Research", title="{ConnectedGraphQ}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/ConnectedGraphQ.html}", note=[Accessed: 29-May-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_connectedgraphq, organization={Wolfram Research}, title={ConnectedGraphQ}, year={2010}, url={https://reference.wolfram.com/language/ref/ConnectedGraphQ.html}, note=[Accessed: 29-May-2025 ]}

@online{reference.wolfram_2025_connectedgraphq, organization={Wolfram Research}, title={ConnectedGraphQ}, year={2010}, url={https://reference.wolfram.com/language/ref/ConnectedGraphQ.html}, note=[Accessed: 29-May-2025 ]}