文件名称:dijkstra
介绍说明--下载内容均来自于网络,请自行研究使用
clear all
clc
D=[0 6 inf inf 5 6 inf 5 inf
6 0 9 inf inf 9 inf 3 inf
inf 9 0 7 inf inf 4 inf inf
inf inf 7 0 6 4 6 inf 3
5 inf inf 6 0 5 inf inf 4
6 9 inf 4 5 0 5 inf inf
inf inf 4 6 inf 5 0 inf inf
5 3 inf inf inf inf inf 0 inf
inf inf inf 3 4 inf inf inf 0]
[m,n]=size(D)
E=zeros(m,n)
for s=1:m
d=inf.*ones(1,m)
d(1,s)=0
ok=zeros(1,m)
pre=zeros(1,m)
while length(find(ok==1))<m
minD=inf
for k=1:m
if ok(k)==0&&minD>d(k)
minD=d(k)
y=k
end
end
if minD==inf
break
-clear all
clc
D=[0 6 inf inf 5 6 inf 5 inf
6 0 9 inf inf 9 inf 3 inf
inf 9 0 7 inf inf 4 inf inf
inf inf 7 0 6 4 6 inf 3
5 inf inf 6 0 5 inf inf 4
6 9 inf 4 5 0 5 inf inf
inf inf 4 6 inf 5 0 inf inf
5 3 inf inf inf inf inf 0 inf
inf inf inf 3 4 inf inf inf 0]
[m,n]=size(D)
E=zeros(m,n)
for s=1:m
d=inf.*ones(1,m)
d(1,s)=0
ok=zeros(1,m)
pre=zeros(1,m)
while length(find(ok==1))<m
minD=inf
for k=1:m
if ok(k)==0&&minD>d(k)
minD=d(k)
y=k
end
end
if minD==inf
break
clc
D=[0 6 inf inf 5 6 inf 5 inf
6 0 9 inf inf 9 inf 3 inf
inf 9 0 7 inf inf 4 inf inf
inf inf 7 0 6 4 6 inf 3
5 inf inf 6 0 5 inf inf 4
6 9 inf 4 5 0 5 inf inf
inf inf 4 6 inf 5 0 inf inf
5 3 inf inf inf inf inf 0 inf
inf inf inf 3 4 inf inf inf 0]
[m,n]=size(D)
E=zeros(m,n)
for s=1:m
d=inf.*ones(1,m)
d(1,s)=0
ok=zeros(1,m)
pre=zeros(1,m)
while length(find(ok==1))<m
minD=inf
for k=1:m
if ok(k)==0&&minD>d(k)
minD=d(k)
y=k
end
end
if minD==inf
break
-clear all
clc
D=[0 6 inf inf 5 6 inf 5 inf
6 0 9 inf inf 9 inf 3 inf
inf 9 0 7 inf inf 4 inf inf
inf inf 7 0 6 4 6 inf 3
5 inf inf 6 0 5 inf inf 4
6 9 inf 4 5 0 5 inf inf
inf inf 4 6 inf 5 0 inf inf
5 3 inf inf inf inf inf 0 inf
inf inf inf 3 4 inf inf inf 0]
[m,n]=size(D)
E=zeros(m,n)
for s=1:m
d=inf.*ones(1,m)
d(1,s)=0
ok=zeros(1,m)
pre=zeros(1,m)
while length(find(ok==1))<m
minD=inf
for k=1:m
if ok(k)==0&&minD>d(k)
minD=d(k)
y=k
end
end
if minD==inf
break
(系统自动生成,下载前可以参看下载内容)
下载文件列表
dijkstra.m