BFS explores the graph level by level, starting from the source node and progressively moving to nodes at increasing distances.
It processes all the neighbors of the current node before moving on to the next level of nodes.
In other words, it visits all the nodes at a distance of 1 from the source, then all the nodes at a distance of 2, and so on.
This level-by-level exploration ensures that BFS reacheseach node in the shortest possible number of steps (edges) from the source.
The queue follows the FIFO order, meaning that the nodes are processed in the order they are discovered.
This FIFO order guarantees that the nodes closer to the source are processed before the nodes farther away.
Algorithm: r m* w a*
(remove, mark*, work, add*)