The textbook used in our class defines a connected (undirected) graph if for any two vertices $v,w\in G$ there is a path from $v$ to $w$. The examples used in the textbook show a visualization of a graph and say "observe that G is connected" or "notice that G is connected". Is there a method to determine if a graph is connected solely by looking at the set of edges and vertices (without relying on inspection of a visualization)?
2026-03-26 04:30:18.1774499418
On
Is there a method for determining if a graph (undirected) is connected?
1.5k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
3
There are 3 best solutions below
0
On
You could also run algorithms such as Dijkstra's, repeating it $n = |V|$ times for each node in the graph. It would give the distance from every vertex to every other, so you just check it is finite for all.
Alternatively, using the adjacency matrix $M$ of the graph, you can compute $\sum_{i=1}^{n} M^i$ and check that all the entries are strictly positive, meaning there exist a path from every pair of vertex to every other in $n$ step or less.
Yes you could, but when you are human (and not a computer), I recommend you do not.
There are several ways to formally write "A graph is connected", e.g.:
You could check these by hand, e.g. to check 1. you can just write down all possible proper subsets of $V$ and then for each write down some edge connecting it with its complement. Checking 3. is more efficient, and when you are a computer this is how I would let you do it:
Let $S$ be the set of all vertices connected to $v_0$. We will construct $S$ as follows (This is a "greedy" approach):