Breadth-First-Search
for each u ∈ G.V - {s} u.color = white s.color = gray s.d = 0 Q = ∅ Q.enqueue(s) while Q ≠ ∅ u = Q.dequeue() for each v ∈ G.Adj[u] if v.color == white v.color = gray v.d = u.d + 1 v.pred = u Q.enqueue(v) u.color = black