CF1037D Valid BFS?
The BFS algorithm is defined as follows.
- Consider an undirected graph with vertices numbered from 1
to n. Initialize q as a new queue containing only vertex 1, mark the vertex 1
- as used.
- Extract a vertex v
- .
- Print the index of vertex v
- .
- Iterate in arbitrary order through all such vertices u