How it works
Queue-based traversal
Use a queue and a visited set to process nodes in expanding layers from the source.
Shortest paths
Because BFS expands by distance, the first time it reaches a node is via a shortest unweighted path.
When to use it
Prefer BFS for level-order traversal, shortest path in unweighted graphs, and minimum-step problems.