Graph Traversal Simulator
Generate an undirected graph, drag the nodes, and watch Breadth-First Search or Depth-First Search visit the graph step by step.
Ready.
Breadth-First Search
BFS uses a queue. It visits all currently reachable neighbors before moving to the next depth level. Its time complexity is O(V + E).
Depth-First Search
DFS uses a stack-like strategy. It follows one branch as deeply as possible before backtracking. Its time complexity is also O(V + E).