It has suddenly occured into my mind.
Why do we use only 2 colors in BFS graphs traveral
and 3 are needed for DFS ?
for instance: from wikipedia:
BFS:
procedure BFS(G,v):
2 create a queue Q
3 enqueue v onto Q
4 mark v
5 while Q is not empty:
6 t ← Q.dequeue()
7 if t is what we are looking for:
8 return t
9 for all edges e in G.adjacentEdges(t) do
12 u ← G.adjacentVertex(t,e)
13 if u is not marked:
14 **mark u**
15 enqueue u onto Q
16 return none
DFS:
procedure DFS(G,v):
2 label v **as explored**
3 for all edges e in G.adjacentEdges(v) do
4 if edge e is unexplored then
5 w ← G.adjacentVertex(v,e)
6 if vertex w is unexplored then
7 label e as a **discovery edge**
8 recursively call DFS(G,w)
9 else
10 label e as a **back edge**
why are 2 colors not enough for DFS?
why are 3 colors reduant for BFS?
here is another BFS (this time 3 colors):

There are a different number of colors in each of the two algorithms because they are used to represent fundamentally different types of information.
In both BFS and DFS, nodes need to be marked as either unexplored nodes or explored nodes. Two colors are needed at a minimum to represent this information.
In the DFS implementation you have listed above, the implementation also uses colors to classify edges as either “discovery edges” (edges that form the depth-first search tree produced by the algorithm) or “back edges” (edges that move from a deeper part of the DFS tree to a shallower part of the DFS tree). These colors are used to color edges, not nodes. As a result, three colors are necessary for edges – unexplored edges, “discovery” edges, and back edges.
Hope this helps!