Run to execute this JavaScript code for real (output appears here).
Queue (front → rear)
Traversal order
Ready.
Explores the graph level by level using a queue. Because vertices are discovered in order of distance, BFS also finds the shortest path (fewest edges) from the start in an unweighted graph. Press Run (Ctrl + Enter) to animate, or Step forward (F10) to go one event at a time.
Step
1 / 78
Line (JavaScript)
—
—
main (no active function frames)
No counted operations yet.
order = []