Dijkstra算法步骤
(1)构造邻接矩阵
(2)定义起始点
(3)运行代码
M=[ 0 5 9 Inf Inf Inf InfInf 0 Inf Inf 12 Inf InfInf 3 0 15 Inf 23 InfInf 6 Inf 0 Inf 8 7Inf 12 Inf 5 0 Inf 14Inf Inf Inf Inf Inf 0 10Inf Inf Inf Inf Inf Inf 0];
first=2;
last=4;
[m,n]=size(M);
L=zeros(1,m);
symbol=zeros(1,m);
direction=zeros(1,m);
for i=1:mif(i~=first)L(i)=inf;enddirection(i)=first;
end
judge=1;
while judge
for i=1:mif(symbol(i)==0)min=L(i);temporary=i;breakend
end
for i=1:mif(symbol(i)==0)if(L(i)<min)min=L(i);temporary=i;endend
end
k=temporary;
for j=1:mif(symbol(1,j)=&