CSE221 · Algorithms

BFS Simulator

Build your own graph, then step through the queue as breadth-first search sweeps it level by level.

ABCDEFGH

Start at A: mark it discovered and put it in the queue.

step 1 of 32
expanding nowinspectingin frontierdone / in treeuntouched

Breadth First Search

Explores every node one level at a time using a FIFO queue, so the first time it reaches a node is along the fewest edges.

Time
O(V + E)

Queue (FIFO)

A

Highlighted entry comes out next.

Build your graph

—

Edges (11)

  • A — B
  • A — D
  • B — C
  • B — E
  • C — F
  • D — E
  • D — G
  • E — F
  • E — G
  • F — H
  • G — H
Start node

← → to step, or use the buttons above.