prim最小树调试 哪里出错了 求高手指点
function=Primf(Z)% 表示邻接矩阵
%c表示生成树的权和
% T表示生成树的边集合
l=length(Z);
a(a==0)=inf;
k=1:l;
listV(k)=0;
listV(l)=l;
e=1;
while(e<1)
min=inf;
for i=1:l
if listV(i)==1
for j=1:l
if listV(j)==0 & min>Z(i,j)
min=a(i,j);
b=a(i,j);
s=i;
d=j;
end
end
end
end
listV(d)=l;
distance(e)=b;
source(e)=s;
destinantion(e)=d;
e=e+1;
end
T=;
for g=1:e-1
c(g)=Z(T(1,g),T(2,g));
end
c;
{:3_42:}{:3_42:}{:3_42:}{:3_42:}{:3_42:}{:3_49:}{:3_49:}{:3_50:}{:3_59:}
页:
[1]