Frequently Asked Questions
Everything you need to know about the BFS & DFS Visualizer.
What is BFS (breadth-first search)?
BFS explores a graph level by level, visiting all of a node's direct neighbors before moving further out, using a queue (first-in, first-out) to track which node to visit next.
What is DFS (depth-first search)?
DFS explores as far as possible along one branch before backtracking, using a stack (last-in, first-out) to track which node to visit next.
What's the main difference between BFS and DFS?
BFS spreads outward evenly and finds the shortest path in an unweighted graph; DFS dives deep into one path first, which can use less memory but doesn't guarantee the shortest path.
How do I enter a graph?
One line per node, formatted as 'Node: neighbor1, neighbor2' — for example 'A: B, C'. Edges are treated as undirected, so listing A connected to B also connects B to A.
What does the queue or stack panel show?
It shows which nodes are waiting to be visited next, in the order they'll be processed — first-in-first-out for BFS's queue, last-in-first-out for DFS's stack.
Why might BFS and DFS visit nodes in a different order?
Because they use different data structures to decide what to explore next — BFS always processes the oldest discovered node first, while DFS always processes the most recently discovered node first.
What happens with disconnected graphs?
This visualizer only traverses nodes reachable from the chosen start node — nodes in a separate disconnected component won't appear in the visited order.
Where are BFS and DFS used in practice?
BFS is used for shortest-path problems and level-order processing; DFS is used for cycle detection, topological sorting, and maze/puzzle solving.
Can I step backward through the traversal?
Yes — use the Prev Step button to move backward and review earlier states of the visited order and queue/stack.
Is this visualizer free to use?
Yes, completely free with no sign-up, and it runs entirely in your browser.