Dijkstra Algorithm

版本 1.0.0.0 (2.6 KB) 作者: Dimas Aryo
Dijstra algorithm to solve shortest path problem.
16.8K 次下载
更新时间 2012/4/11

查看许可证

This algorithm is to solve shortest path problem.

Usage
[cost rute] = dijkstra(graph, source, destination)

note : graph is matrix that represent the value of the edge. if node not connected with other node, value of the edge is 0.

example:
Finding shortest path form node 1 to node 7.

>> G = [0 3 9 0 0 0 0;
0 0 0 7 1 0 0;
0 2 0 7 0 0 0;
0 0 0 0 0 2 8;
0 0 4 5 0 9 0;
0 0 0 0 0 0 4;
0 0 0 0 0 0 0;
];
>> [cost rute] = dijkstra(G,1,7)

it will resulting

cost = 15
rute = [7 6 4 5 2 1]

引用格式

Dimas Aryo (2026). Dijkstra Algorithm (https://ww2.mathworks.cn/matlabcentral/fileexchange/36140-dijkstra-algorithm), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R14SP1
兼容任何版本
平台兼容性
Windows macOS Linux
版本 已发布 发行说明
1.0.0.0