HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Reversing topo-order of the original graph instead of the topo-order of the transposed graph?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
theordergraphtransposedoriginaltopoinsteadreversing

Problem

(Note that my question is different from this one, I understand why we have to do a dfs on a reversed graph, I want to understand why we can't reverse the topological order instead of transposing the graph.)

In Kosaraju's algorithm, it is stated to compute the transposed graph and apply topological sort on it. I understand why this is necessary.

What I don't understand is the necessity to actually compute the transposed graph. Can't we just apply the topological sort algorithm on the original graph and use the resulting list in reverse order?

In Dasgupta,Papadimitriou, Vazirani, one can read


There is not an easy, direct way to pick out a node that is guaranteed
to lie in a sink strongly connected component.

I am having trouble to see why. If I apply a explore on any node of the following graph, the first finished node will be one of inside a sink strongly connected component.

Wikipedia's description of the algorithm seems to confirm this. The first DFS prepends instead of appending.

Can someone show an example (if any) where using the reversed topological order of the original graph instead of the topological order of the transposed graph is wrong?

Solution

It may work for the graph you give, but not for all graphs. Consider a graph with 3 vertices, A, B, and C.

$A \rightarrow B, C$

$B \rightarrow A$

Search on A, exploring B before C, B finishes first but is not in a sink.

Also, note that for the Wikipedia article, the search is on incoming edges, not outgoing, which is why it doesn't need to explicitly transpose the graph.

Context

StackExchange Computer Science Q#60503, answer score: 3

Revisions (0)

No revisions yet.