Graph visualizer

Depth-First Search

Explore deeply along each branch using a stack.

Best O(1)Average O(V + E)Worst O(V + E)Space O(V)
Example Graph
A-B, A-C, B-D, B-E, C-F, C-G, E-H, F-H

Visualization

Ready
Ready to traverse from A using a stack.Target: F
ABCDEFtargetGH
FrontierEmpty
CurrentFrontierVisitedFound

Metrics

Comparisons0
Visited0
Progress0%
Time taken0.0s

Pseudocode

  1. dfs(graph, start, target)
  2. stack = [start]
  3. visited = empty set
  4. while stack is not empty
  5. node = stack.pop()
  6. check node
  7. if node == target: return node
  8. mark node as visited
  9. for each unvisited neighbor
  10. push neighbor onto stack
  11. return not found