Watch Breadth-First Search (BFS) find paths through complex grids. Interactive matrix explorations.
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.
Explores the grid level-by-level, radiating outwards from the source. Guarantees the shortest path on an unweighted grid.
Explores as far as possible along each branch before backtracking. Does not guarantee the shortest path.
Click or drag over cells to toggle walls (obstacles). The algorithm will avoid these walls when searching for the target.
V is the number of cells (rows × cols), and E is the number of connections between cells (at most 4 for each). BFS is ideal for unweighted grids, while DFS is rarely used for shortest paths but great for exploring entire mazes.