Core idea
BFS starts from one source vertex and explores neighbors level by level.
A queue preserves the order of discovery.
It finds shortest paths in unweighted graphs.
How it works
- Push the start vertex into a queue and mark it visited.
- Remove the front vertex from the queue.
- Visit each unvisited neighbor and push it into the queue.
- Repeat until the queue is empty.