Skip to content
PixelCursor(opens in a new tab)
Computer Science

Graph Algorithms Visualizer

Visualize pathfinding algorithms like BFS, DFS and Dijkstra

Breadth-first search (BFS) · Uninformed
Speed: medium
Search

Press Search and watch BFS find its way through the walls. Drag on the grid to change them.

  • Start
  • Goal
  • Wall
  • Frontier
  • Explored
  • Path

Your runs

Runs finished0
Tried0of 5
Cells searched0

Run a search to the end and it counts here, saved on this device only.

Breadth-first search (BFS)

Spreads out in rings: every cell at distance 1, then every cell at distance 2, and so on. The first time it touches the goal, it has found a shortest path.

Time
O(V + E)
Memory
O(V)
Shortest pathWorks with weights
  • Keeps a queue: first in, first out
  • Shortest path on grids where every step costs the same
  • Explores in every direction, also away from the goal

All five on this grid

Live

Same walls, same start and goal: how many cells each search explores and how long its path is.

  • 10229 steps
  • 162115 steps
  • 10229 steps
  • 5329 steps
  • 31fewest29 steps

About this tool

  • It is all about the frontier

    Every search here keeps a list of cells to look at next. A queue makes BFS, a stack makes DFS, a priority by distance makes Dijkstra.

  • A good guess saves work

    A* adds an estimate of the remaining distance. As long as it never overestimates, the path stays the shortest and far fewer cells get explored.

  • Found in every map

    Route planners, game characters, network packets: they all find their way with relatives of these five algorithms.

Keyboard

Space
Search, pause or resume
←→
One step back or forward
R
Clear the search
M
New maze
W
Clear all walls
15
Pick algorithm 1 to 5
-+
Slower or faster