function DepthFirstSearch(G) {
for each vertex u in G.V {
u.color = white
u.phi= NaN
}
time = 0
//Step = 0
for each vertex u in G.V {
if (u.color is white) {
VisitNext(G, u)
}
}
}
function VisitNext(G, u) {
time=time+1
u.d=time
u.color= grey
//Step++
for each v in G.AdjacencyList[u] {
if (v.color is white) {
v.phi=u
VisitNext(G,v)
}
}
u.color= black
time=time+1
u.f=time
//Step++
}
G is shown below.for loop of the DepthFirstSearch procedureG is shown below. for loop of the DepthFirstSearch procedure