This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

ConnectedGraphQ

ConnectedGraphQ[g]
yields True if the graph g is connected, and False otherwise.
  • A graph is connected if there is a path between every pair of vertices.
Test whether a graph is connected:
A graph with isolated vertices is not connected:
Test whether a graph is connected:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
 
A graph with isolated vertices is not connected:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
Test undirected graphs:
Directed graphs:
Test larger graphs:
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:
A connected graph has vertex degree greater than for the underlying simple graph:
A disconnected graph:
An undirected tree is connected:
An undirected path is connected:
New in 8