Two fundamental ways to explore any graph. Breadth-first fans out level by level; depth-first plunges deep and backtracks. Watch the visit order diverge.
Graph Traversal (BFS / DFS)Live
breadth vs depth
Controls
The two ways to explore a graph. Breadth-first search fans out level by level using a queue, visiting all near nodes before far ones — ideal for shortest paths. Depth-first search plunges as deep as possible using a stack, backtracking when stuck — ideal for cycle detection and topological sorting. Watch the numbered visit order differ.
Reading this result: BFS uses a FIFO queue, so it fully visits every node at distance 1 before any at distance 2 — that level-by-level order is exactly why it finds shortest paths in unweighted graphs.
Runs locally in your browser — free forever. Scale to the cloud when reality gets heavy.
★ Sign in to save this setupSave your tuned setup, or drop this simulation into your own site, docs, or course page.
How it works
Breadth-first search uses a queue to visit all nearby nodes before far ones, making it perfect for shortest paths and level-order processing. Depth-first search uses a stack to dive as deep as possible before backtracking, ideal for cycle detection, topological sorting, and maze solving. The numbered visit order shows exactly how the two strategies differ.
✦
Ask the AI about this model
The math, the assumptions, real-world uses, or a code translation — explained for this exact simulation.
Is this BFS DFS graph traversal tool really free?▾
Yes. Graph Traversal (BFS / DFS) runs entirely in your browser using your device's own compute, so local use is free forever. You only pay Compute Tokens if you scale a job to the cloud.
Do I need to install anything?▾
No. Everything runs client-side in a modern browser — no downloads, no license, no account required to start.
Can I save or share my simulation?▾
Create a free account to save projects, and use a shareable embed or minted DOI to publish a live, interactive version anywhere.
How accurate are the results?▾
The solver uses established numerical methods, but results are for research and educational purposes and should be validated against experiment or professional review before you rely on them.