I have the following pseudocode for breadth-first search algorithm
BFS(G,s)
1 for each vertex u ∈ V(G) \ {s}
2 color[u] = white
3 d[u] = ∞
4 π[u] = nil
5 color[s] = gray
6 d[s] = 0
7 π[s] = nil
8 Q = ∅
9 Enqueue(Q,s)
10 while q ≠ ∅
11 u = Dequeue(Q)
12 for each v ∈ Adj[u]
13 if color[v] == white
14 color[v] = gray
15 d[v] = d[u] + 1
16 π[v] = u
17 Enqueue(Q,v)
18 color[u] = black
I do not understand what the letter π indicates in this context. I am not familiar with this algorithm and it is a difficult to guess.
I think d
indicates the distance, color
is of course the color, but that π
... it appears to be a variable of some sort but I do not understand its function in this pseudocode.