Paint walls on an N×M grid, set start and end cells, then run BFS to visualize the shortest path. Copy the grid as a C++ 2D vector instantly.
Breadth-first search finds a shortest path on an unweighted grid because it expands in rings, so the first time it reaches a cell it has arrived by the fewest possible steps. The Grid Path Finder draws those rings. Paint walls, drop a start and an end, and watch the frontier spread before the path is traced back through it.
Two colours carry the whole idea. Blue marks every cell the search visited, yellow marks the shortest path itself, and the gap between the two areas is the work BFS did that the answer did not need. On an open grid that gap is enormous, which is the honest picture of the algorithm.
Movement is 4-directional, up, down, left and right, with no diagonals, which is the standard convention for grid problems. Everything computes in the page and nothing is uploaded.
Copy Grid as C++ 2D Vector
vector<vector<int>> grid = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};
// 0 = empty, 1 = wall