input: Graph G. output: array p pointing to predecessor vertex, array d with times of vertex opening and array f with time of vertex closing
procedure DFS-Walk(Vertex u) {
state[u] = OPEN;
for each Vertex v in succ(u)
if (state[v] == UNVISITED) then {
DFS-Walk(v );
}
state[u ] = CLOSED;
}
DFS-Walk-push(Vertex u) {
state[u] = OPEN;
d[u] = ++time;
for each Vertex v in succ(u)
if (state[v ] == UNVISITED) then {
p[v] = u;
DFS-Walk-push(v);
}
state[u] = CLOSED;
f[u] = ++time;
push u to S;
}