[G10] Strong connectivity (3 pts) [00MW]
In class, we saw the definition of an undirected graph which is connected: a graph is connected if there is always a path between any two vertices. When we add directions to the edges, the concept of connectedness becomes more interesting.
A directed graph is strongly connected if for any two vertices x and y, there is always a directed path from x to y. Note this must also be true for the vertices y and x, so there must be a directed path from y to x as well. In other words, a strongly connected graph is like a network of one-way streets where it is always possible to drive from any location to any other location while obeying the one-way signs; you can never get stuck.
This problem will walk you through the process of developing an algorithm for determining whether a directed graph is strongly connected.
- Give an example of a strongly connected graph with at least 4 vertices (you may either draw it, or list its vertices and edges).
- Prove: a directed graph G is strongly connected if and only if there is some vertex s such that s is mutually connected to every other vertex; that is, for every other vertex v there is both a directed path from s to v and also from v back to s.
- Explain how to use a graph search algorithm like DFS or BFS to determine whether there exist directed paths from a particular starting vertex s to every other vertex.
- Explain how to determine, in only O(V+E) time, whether there exist directed paths to a particular vertex s from every other vertex.
- Put all these observations together into an algorithm to determine whether a given directed graph is strongly connected. You should:
- Describe your algorithm. You may use pseudocode, but your description should be detailed enough that someone could take it and turn it into working code.
- Prove/justify the correctness of your algorithm. In other words, why does your algorithm correctly determine whether a graph is strongly connected? Of course, you may freely cite the results from the previous parts of this problem.
- Analyze the asymptotic running time of your algorithm.