BFS & DFS Graph Explorer
Follow how a queue drives breadth-first search and how recursive calls drive depth-first search. Both methods use the same graph and alphabetical neighbor order. Discovery and completion are separate events; Back lets you revisit any decision.
Changing traversal settings prepares a fresh run on this graph. Apply edges after editing. Reset replays the same run.
Graph
Blue edges form the traversal forest; the orange edge is being examined. Directed edges follow arrowheads.
Current step
Queue · front → back
Discovery order
Completion order
Traversal record
| Vertex | Parent | BFS distance / DFS depth | State |
|---|
BFS distances are shortest edge counts from each component root in an unweighted graph. DFS depth describes the call tree and is not generally a shortest distance. Adjacency-list traversal takes Θ(V + E) for a complete traversal; each undirected edge is examined from both endpoints.