Maze as a Graph
A maze can be modeled as a graph where each walkable cell is a vertex and an edge connects cells that can be reached directly. BFS finds the shortest path in an unweighted maze, while DFS can determine reachability or find any path. For weighted movement costs, algorithms such as Dijkstra may be required.
Walkable cells become graph vertices.
Adjacent walkable cells become edges.
BFS gives the shortest number-of-moves path.
DFS can find whether a path exists.
A* can accelerate target-directed pathfinding with a suitable heuristic.