Explore a graph from a start node. Breadth-first search fans out level by level using a queue; depth-first search dives deep using a stack.
Explore a graph from a start node. Breadth-first search fans out level by level using a queue; depth-first search dives deep using a stack.
Time complexity: O(V + E). Space complexity: O(V).
Use the interactive visualizer above to run Graph Traversal (BFS & DFS) on your own input and watch every comparison, swap, and operation animate step by step — pause, scrub, or replay at any speed.