Shortest Cityblock Path with Multiple Nodes (Goals) with Still Obstacles
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Pyro
am 31 Okt. 2015
Kommentiert: Image Analyst
am 1 Nov. 2015
I have spent a great deal of time reading about A* search, Dijkstra’s, and Best-First-Search algorithms. I did an exhausutive search of all m-file exhanges, toolboxes, and whatnot, but I couldn't find a solution to my problem.
As the title suggests, I have a square map (you may call it a grid, or a matrix). I have a predefined starting point, and there are predefined still obstacles. There could be as few as one goal, or there could be multiple nodes.
What I need:
I need to find the shortest cityblock path (moving diagonally isn't allowed) that passes through all goals, and plots the path on the original grid with obstacles and starting point indicated.
To help you visualize the problem, see the image
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/151263/image.jpeg)
In this image, the numbers one through eight represent the only possible nodes. The blue blocks are obstacles, and the path cannot pass through it. The gray squares are equivalent to the white ones. I used color just to make it easier to understand the map.
Let me give an example with the desired solution. Assume there are only 2 desired nodes we want to pass by: node 2 and node 8. The output map should look something like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/151264/image.jpeg)
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 31 Okt. 2015
See Steve's blog series on shortest paths. http://blogs.mathworks.com/steve/2011/11/01/exploring-shortest-paths-part-1/
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dijkstra algorithm finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!