Talk:Tarjan's strongly connected components algorithm
Latest comment: 16 years ago by 128.9.216.61 in topic Bug in second subcase
Pseudocode is not good
In this reference web.cecs.pdx.edu we see that TarjanDfs is called not only for first node v0, but all nodes that are not visited. This should be fixed, I am not expert, but here is suggestion.
index = 0 // DFS node number counter S = empty // An empty stack of nodes for each vertex v if v.index is undefined tarjan(v) // Start a DFS at the non-visited node
Bug in second subcase
Seems to me that the second update case is wrong:
Instead of
if (v'.index is undefined) // Was successor v' visited? tarjan(v') // Recurse v.lowlink = min(v.lowlink, v'.lowlink) elseif (v' in S) // Is v' on the stack? v.lowlink = min(v.lowlink, v'.lowlink)
shouldn't it be
if (v'.index is undefined) // Was successor v' visited? tarjan(v') // Recurse v.lowlink = min(v.lowlink, v'.lowlink) elseif (v' in S) // Is v' on the stack? v.lowlink = min(v.lowlink, v'.index)