dsagraphsqueues
mark nodes when they enter the bfs queue
Anonymous
In unweighted BFS, mark a node visited when it enters the queue, not when it leaves. That prevents duplicate enqueues and preserves first-discovery distance. With adjacency lists, traversal takes O(V + E).
0