Visualization sandbox
Which node leaves the queue next?
Try one breadth-first search step. Node 1 has been visited, and its neighbors 2 and 3 are waiting in the queue.
Purple nodes are waiting. The double ring marks the current visit.
BFS queue
Front →23
Choose the next node to visit.
Neighbors enter in ascending order. BFS takes the oldest waiting node first.
Build your own graphs with Interview Prep or Oni.
Edit directed and weighted graphs, or generate trees.
Compare passesCheckout is closed right now.