2

The strongly connected component algorithm from my book:

strongly-connected-component(G)

  1. call DFS(G) to compute finishing times f[u] for each vertex u
  2. compute Transpose(G)
  3. call DFS(Transpose(G)), but in the main loop of DFS, consider the vertices in order of decreasing f[u] (as computed in line 1)
  4. output the vertices of each tree in the depth-first forest of step 3 as a separate strong connected component

I do not really understand how line 4 works, how the algorithm makes the forest from the DFS on the transpose graph. I do understand why to call both times to DFS.

Thanks for any help.

G. Bach
  • 3,869
  • 2
  • 25
  • 46
korkotyan
  • 53
  • 9
  • Stackoverflow is about code. For questions about pseudo-code and algorithms, you should rather ask on http://programmers.stackexchange.com – oberlies Apr 20 '14 at 15:22
  • @oberlies this is handled totally inconsistently so I don't think there's a community consensus about that. By the way I think cs.SE would be the best fit for this post – Niklas B. Apr 20 '14 at 15:28
  • Have an upvote, I for one think that that algorithm is not entirely trivial, so I don't see why this should be downvoted. – G. Bach Apr 21 '14 at 12:03

1 Answers1

2

The DFS main loop calls a recursive helper function on each vertex to explore the vertices reachable from that vertex. A "tree" here is the set of vertices newly visited by one of these recursive calls. The helper function must be modified to construct this set, which is a strong component whenever it is nonempty.

David Eisenstat
  • 64,237
  • 7
  • 60
  • 120