Pathfinding Visualizer

Draw walls, move start/end nodes, and visualize shortest path algorithms.

Start
End
Wall
Visited
Frontier
Path

Nodes Visited

0

Path Length

0

Steps Elapsed

0

Algorithm Source
1function bfs(start, end) {
2  let queue = [start];
3  let visited = new Set();
4  visited.add(start);
5  while (queue.length > 0) {
6    let curr = queue.shift();
7    if (curr === end) return buildPath();
8    for (let neighbor of getNeighbors(curr)) {
9      if (!visited.has(neighbor) && !isWall(neighbor)) {
10        visited.add(neighbor);
11        parent[neighbor] = curr;
12        queue.push(neighbor);
13      }
14    }
15  }
16}