GraphTheory
IsConnected
test if graph is connected
ConnectedComponents
compute connected components of graph
Calling Sequence
Parameters
Description
Definition
Examples
IsConnected(G)
ConnectedComponents(G)
G
-
graph
IsConnected returns true if the input graph is a connected graph or false otherwise. If G is a directed graph then the directions of edges are ignored. Use the IsStronglyConnected command to test whether each pair of vertices is connected by a directed path.
ConnectedComponents returns the components of the graph as a list of lists of vertices. Each sublist is a list of vertices for a connected component.
A graph G is connected if for each pair of vertices u and v in G there exists a path from u to v in G (if G is undirected), or in the underlying graph of G (if G is directed).
with⁡GraphTheory:
with⁡SpecialGraphs:
G≔CycleGraph⁡4
G≔Graph 1: an undirected graph with 4 vertices and 4 edge(s)
IsConnected⁡G
true
H≔GraphComplement⁡G
H≔Graph 2: an undirected graph with 4 vertices and 2 edge(s)
IsConnected⁡H
false
ConnectedComponents⁡H
1,3,2,4
DrawGraph⁡H
G≔Graph⁡1,2,3,4,5,6,1,2,2,3,4,5
G≔Graph 3: an undirected graph with 6 vertices and 3 edge(s)
ConnectedComponents⁡G
1,2,3,4,5,6
G≔OctahedronGraph⁡
G≔Graph 4: an undirected graph with 6 vertices and 12 edge(s)
H≔Graph 5: an undirected graph with 6 vertices and 3 edge(s)
DrawGraph⁡G
See Also
ArticulationPoints
GraphRank
IsBiconnected
IsReachable
IsStronglyConnected
IsTwoEdgeConnected
StronglyConnectedComponents
UnderlyingGraph
Download Help Document