Graph visualizer

Breadth-First Search

Explore a graph level by level using a queue.

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 queue.Target: F
ABCDEFtargetGH
FrontierEmpty
CurrentFrontierVisitedFound

Metrics

Comparisons0
Visited0
Progress0%
Time taken0.0s

Pseudocode

  1. bfs(graph, start, target)
  2. queue = [start]
  3. mark start as discovered
  4. while queue is not empty
  5. node = queue.removeFront()
  6. check node
  7. if node == target: return node
  8. for each neighbor of node
  9. if neighbor is unvisited
  10. add neighbor to queue
  11. return not found