英语翻译clc;clear all;close all;A =[ 0 1 Inf Inf 4 5 10 7;0 0 Inf Inf Inf Inf 7 2;0 0 0 1 Inf Inf 8 5;0 0 0 0 6 9 Inf 3;0 0 0 0 0 Inf Inf 4;0 0 0 0 0 0 4 Inf;0 0 0 0 0 0 0 Inf0 0 0 0 0 0 0 0];W=A+A';D=[];T=[];S=[];i=1;m=length(W);S(1,1)=i;V=1:m;V

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 01:28:39
英语翻译clc;clear all;close all;A =[ 0 1 Inf Inf 4 5 10 7;0 0 Inf Inf Inf Inf 7 2;0 0 0 1 Inf Inf 8 5;0 0 0 0 6 9 Inf 3;0 0 0 0 0 Inf Inf 4;0 0 0 0 0 0 4 Inf;0 0 0 0 0 0 0 Inf0 0 0 0 0 0 0 0];W=A+A';D=[];T=[];S=[];i=1;m=length(W);S(1,1)=i;V=1:m;V

英语翻译clc;clear all;close all;A =[ 0 1 Inf Inf 4 5 10 7;0 0 Inf Inf Inf Inf 7 2;0 0 0 1 Inf Inf 8 5;0 0 0 0 6 9 Inf 3;0 0 0 0 0 Inf Inf 4;0 0 0 0 0 0 4 Inf;0 0 0 0 0 0 0 Inf0 0 0 0 0 0 0 0];W=A+A';D=[];T=[];S=[];i=1;m=length(W);S(1,1)=i;V=1:m;V
英语翻译
clc;clear all;close all;
A =[ 0 1 Inf Inf 4 5 10 7;
0 0 Inf Inf Inf Inf 7 2;
0 0 0 1 Inf Inf 8 5;
0 0 0 0 6 9 Inf 3;
0 0 0 0 0 Inf Inf 4;
0 0 0 0 0 0 4 Inf;
0 0 0 0 0 0 0 Inf
0 0 0 0 0 0 0 0];
W=A+A';
D=[];T=[];S=[];
i=1;m=length(W);
S(1,1)=i;V=1:m;V(i)=[];D=[0;i];
n=2;[mD,nD]=size(D);
while isempty(V)
[td,j]=min(W(i,V));
tj=V(j);
for k=2:nD
[t1,jj]=min(D(1,k)+W(D(2,k),V));
t2=V(jj);T(k-1,:)=[t1,t2,jj];
end
t=[td,tj,j;T];[t3,t4]=min(t(:,1));
if t3==td
S(1:2,n)=[i;t(t4,2)];
else
t5=find(S(:,t4)~=0);
t6=length(t5);
if D(2,t4)==S(t6,t4)
S(1:t6+1,n)=[S(t5,t4);t(t4,2)];
else
S(1:3,n)=[i;D(2,t4);t(t4,2)];
end;
end
D=[D,[t3;t(t4,2)]];V(t(t4,3))=[];
[mD,nD]=size(D);n=n+1;
end;
S,D

英语翻译clc;clear all;close all;A =[ 0 1 Inf Inf 4 5 10 7;0 0 Inf Inf Inf Inf 7 2;0 0 0 1 Inf Inf 8 5;0 0 0 0 6 9 Inf 3;0 0 0 0 0 Inf Inf 4;0 0 0 0 0 0 4 Inf;0 0 0 0 0 0 0 Inf0 0 0 0 0 0 0 0];W=A+A';D=[];T=[];S=[];i=1;m=length(W);S(1,1)=i;V=1:m;V
这是迪克斯特拉算法