04 Try it yourself Interactive

Same graph, same code, swap the container

The seven-edge graph from section 02 and the ten lines from section 03. Tab across to DFS and only the frontier changes. Amber nodes are marked but still waiting; green ones have been taken out. Change the graph, change the start node, or type your own edges. Nothing moves until you press Next.

Breadth-first
frontier = queue · oldest out first
Up to 12 edges between nodes 0 and 5, each written a-b.
Frontier · queue
next out at the top · new nodes join at the bottom
Visit order
Press Next to begin. Each press moves one step.


      
Current node–
Frontier0
Taken out0
Edge checks0
step 0 / 0