File Exchange

image thumbnail

Solve the puzzle via djstra shortest path algorithm

version (24.1 KB) by Su Dongcai
an interesting application of djstra algorithm


Updated 20 Jan 2012

View License

This file apply djstra algorithm(only consider the positive edge weight case) to solve the
puzzle and visualize the result.
Please run the following commands to duplicate the screen shot(have fun :):

mex vcDjstra.cpp;%compile the cpp file
im = imread('puzzle.png'); im = rgb2gray(im);
[pc, path] = shortestPath(im, [57, 94], [471, 496]);
The puzzle.png is from steven's blog:
The core file that implement djstra algorithm is 'cShortestPath.h', the compiler I used in
msvc++ 6.0

Cite As

Su Dongcai (2020). Solve the puzzle via djstra shortest path algorithm (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (0)


Fix a bug on line59 'cShortestPath.h', where I erroneously written operator '%' instead of '/', this bug result in the incorrect path cost 'pc'

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