Search code examples
graph-algorithmdepth-first-searchstrongly-connected-graph

Let G be a directed graph. There is a special vertex S such that there is a path to this vertex from every other vertex of the graph


To check if a vertex v is a special vertex is it sufficient to show that it is in a sink Strongly connected component? Don't we have to also prove that the underlying undirected graph is connected? If that is the case, what is the best way to check if a vertex is special


Solution

  • It is not sufficient to show that v is in a sink SCC, even if we knew that the undirected form of the graph is connected. This is because there may be multiple sink SCCs and one sink cannot be reached from another.

    If your question is: "given a vertex v, what is the best way to determine if v is reachable from every other vertex of the graph," then you should start at v and follow all of the edges backwards. If you can reach every vertex by following edges backwards, then that means v is reachable from every other vertex of the graph.

    If you don't have a specific vertex in mind but want to know if there is any vertex that is reachable from every other vertex, it is similar to this problem. You use Tarjan's algorithm to turn your graph into a directed acyclic graph of SCCs. If there is a unique sink SCC in this graph, then every vertex in this sink SCC is reachable from every vertex in the entire graph. If there is more than one sink SCC, then there does not exist a vertex that is reachable from every other vertex in the graph.