Type the BFS discovery step for a white neighbour v of u
Type the BFS discovery step for a white neighbour v of u
Answer
dist[v] = dist[u] + 1 parent[v] = u q.append(v)
When v is first discovered from u, its distance is one more than u’s, its parent is u, and it joins the frontier queue. The white-check (dist[v] == INF) guards this so each vertex enqueues once.