dijkstra
Version 1.0 (2,32 ko) par
Jordi Palacin
Another single-function implementation of Dijkstra's Algorithm for shorter path finding in a directed matrix-graph
A single-function implementation of Dijkstra's algorithm for shorter path finding in a directed matrix-graph
Didactic reference of Dijkstra's algorithm at: https://youtu.be/bZkzH5x0SKU
[route, cost, M] = dijkstra(G, initialNode, finalNode)
Interpretation of the columns of the Dijkstra matrix M
Node number | best previous node | cumulative path cost | node visited
Example: G(a,b)=z defines a directional link from (only) the node a to b, use G(b,a)=w to link from b to a
G = [;
0 1 0 0 0 0 0;
0 0 1 0 0 10 0;
2 0 0 1 0 0 0;
0 0 2 0 1 0 0;
0 0 0 2 0 1 0;
0 0 0 0 2 0 1;
0 0 0 0 0 2 0;
];
[ r, c, W] = dijkstra( G, 1, 7)
r =
1 2 3 4 5 6 7
c =
6
W =
1 0 0 1
2 1 1 1
3 2 2 1
4 3 3 1
5 4 4 1
6 5 5 1
7 6 6 1
Citation pour cette source
Jordi Palacin (2024). dijkstra (https://www.mathworks.com/matlabcentral/fileexchange/134851-dijkstra), MATLAB Central File Exchange. Récupéré le .
Compatibilité avec les versions de MATLAB
Créé avec
R2015b
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Découvrir Live Editor
Créez des scripts avec du code, des résultats et du texte formaté dans un même document exécutable.
Version | Publié le | Notes de version | |
---|---|---|---|
1.0 |