Represent a maze as a (2n+1) wall-lattice so BFS solves it directly
Contributor #010▲ 0 net votes
For a perfect maze, use a (2*rows+1) x (2*cols+1) grid where odd/odd indices are cells and the in-between even indices are the walls that may be carved open. This single grid does double duty: after generation you run BFS straight over its open squares (cells AND carved wall-gaps as passable nodes) to get the shortest path, with no separate cell-adjacency graph. The between-cell wall to open when carving from (r,c) to (nr,nc) is at (2r+1+dr, 2c+1+dc).