BFS & DFS Graph Traversal Visualizer
Compare Breadth-First Search (level-order shortest hop count) against Depth-First Search (recursion stacks, Euler tin[]/tout[] timestamps, and back-edge cycle detection) interactively on your own graph.
BFS vs DFS at a Glance
| Property | BFS (Breadth-First Search) | DFS (Depth-First Search) |
|---|---|---|
| Data Structure | FIFO Queue | Recursion Call Stack |
| Complexity | O(V + E) |
O(V + E) |
| Visualized State | Level distances & Queue snapshot | Call stack, tin/tout, Tree vs Back edges |
| Common CP Problems | Unweighted shortest path, 2-coloring, multi-source grids | Connected components, cycle finding, subtree timestamps |
Sample Traversal Input
# Paste into Edges List 1 2 1 3 2 4 2 5 3 6 5 6 4 7
Related Graph Tools
Topological Sort & Tarjan SCC
Use DFS low-link and in-degree counts on directed graphs to find cycles and condensation DAGs.
Tree Diameter & Double-BFS
Find the exact tree longest path and tree center(s) using two consecutive BFS traversals.
Frequently Asked Questions
What does BFS show in CP Graph Editor?
Each playback step updates the floating data-structure queue view, highlights the frontier edge being inspected, and pins distance labels beneath visited nodes.
Can I run BFS on disconnected multi-component graphs?
Yes. The bottom bar tracks component count in real-time and lets you start from any chosen vertex in the Algorithms panel.