DFS(G)
--for each vertex u belonging to G.V
----u.parent=nil
----u.color=WHITE
--time=0
--for each vertex u belonging to G.V
----if u.color==WHITE
------DFS-Visit(u)
DFS-Visit(G, u)
--time=time+1
--u.discoveryTime=time
--u.color=GRAY
--for each v beloning to G.Adj[u]
----if v.color==WHITE
------v.parent=u
------DFS-Visit(G, v)
--u.color=BLACK
--time=time+1
--u.finishTime=time
BFS(G, s)
--for each vertex u belonging G.V-{s}
----u.color=WHITE
----u.d=MAX
----u.parent=nil
--s.color=GRAY
--s.d=0
--s.parent=nil
--Q={}
--ENQUEUE(Q, s)
--while Q is not empty
----u=DEQUEUE(Q)
----for each v belonging to G.Adj[u]
------if v.color==WHITE
--------v.color=GRAY
--------v.d=u.d+1
--------v.parent=u
--------ENQUEUE(Q. v)
----u.color=BLACk