image thumbnail

A solution to the Maze problem with Dijkstra

version (2.21 KB) by Y Simson
Use Dijkstra to find the shortest path to a Maze


Updated 31 Mar 2014

View License

The general idea:
1) Think of every pixel in the maze as node on a connected graph
2) Define the walls as having high weights. This ensures that walls will act as separators
3) Use a 4-connected neighborhood to link adjacent pixels/nodes
4) Convert the maze image into a sparse Distance matrix(similar to an adjacency matrix with weights instead of ones).
5) Use graphshortestpath() from the bioinformatics toolbox to find the shortest path

Cite As

Y Simson (2022). A solution to the Maze problem with Dijkstra (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: dijkstra very simple

Inspired: Dijkstra lowest cost for images

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!