12.3.2 Testing Graph Connectivity

Consider algorithms for testing to see if an undirected graph is connected. The graph is assumed to have N nodes, N>=2.

Algorithms are allowed only to ask questions of the form: "Is there an edge between i and j?"

If we turn an algorithm that solves this problem into a decision tree, it will have only two distinct verdicts: "connected" and "not connected". From that we can only conclude that the algorithm at least asks *one* question.

Thus information theoretical techniques are of no help in establishing a tight lower bound on the complexity of this problem.

Here is an adversary argument that provides a lot more information:

Partition the node set into two "equal halves" V and W (the sizes are the floor and ceiling of N/2)


V  *  *  *  *  *  *  *  *  *

W  *  *  *  *  *  *  *  *
When the algorithm "Al" asks if an edge exists, the daemon says "yes" if the two nodes are both in V or both in W, else the daemon answers "no".

Suppose Al stops and gives an answer before asking about *every* possible edge between V and W.

If Al says the graph is connected, then the daemon can say "Al, you are wrong, there are no edges between any of the nodes in V and any of the nodes in W."

If Al says the graph is not connected, then the daemon can pick one of the possible edges (v,w) from V to W that Al did not ask about and say: "Al, you are wrong. There is an edge from each node in V to every other node in V. There is an edge from each node in W to every other node in W. There is an edge (v,w) from V to W. Thus the graph is connected."

In both cases, the daemon would be making an assertion that is completely consistent with all the answers it gave to Al.

This shows that in the worst case Al must at least inquire about the existence of the approximately (N/2)*(N/2)=(N^2)/4 possible edges between V and W.

Therefore any algorithm that solves this problem has a worst case complexity that is big-omega of N^2.

Brassard and Bratley note that a more sophisticated adversary argument will show that each of the possible N(N-1)/2 edges must be queried in the worst case. (c.f. problem 12.16)