Algo Visualizer

Matrix Pathfinding

🧀
🐭
Source
Target
Wall
Visited
Path
Debugger · v1.0
LIVE
1function DFS(source, target) {
2 const stack = [source];
3 const visited = new Set([source]);
4 while (stack.length > 0) {
5 const curr = stack.pop();
6 if (curr === target) return reconstructPath();
7 for (const neighbor of getNeighbors(curr)) {
8 if (!visited.has(neighbor) && !neighbor.isWall) {
9 visited.add(neighbor);
10 parent.set(neighbor, curr);
11 stack.push(neighbor);
12 }
13 }
14 }
15}
1x
Matrix Path Finder

Grid Pathfinding Algorithms

Step 1 of 4

Visualize how various algorithms search for a path from a start node (green) to a target node (red) on a 2D grid filled with obstacles.

Breadth-First Search (BFS)

Explores the grid level-by-level, radiating outwards from the source. Guarantees the shortest path on an unweighted grid.

S
1
2
3
1
2
3
4
2
3
4
T
3
4
T
5
Sequential levels of expansion