graph :: TarjanAlgorithm :: visit
# The recursive part of Tarjan's algorithm
fun visit(u: V)
do
vertex_to_index[u] = index
ancestor[u] = index
index += 1
stack.add(u)
in_stack.add(u)
for v in graph.successors(u) do
if not vertex_to_index.keys.has(v) then
visit(v)
ancestor[u] = ancestor[u].min(ancestor[v])
else if in_stack.has(v) then
ancestor[u] = ancestor[u].min(vertex_to_index[v])
end
end
if vertex_to_index[u] == ancestor[u] then
var v
loop
v = stack.take
in_stack.remove(v)
sccs.union(u, v)
if u == v then break
end
end
end
lib/graph/digraph.nit:643,2--668,4