V = [1:100]
w;
L(V(i)) = inf; L(V(1)) = 0;
S = [];
while ~ismember(V(100),S)
U =setdiff(V,S);
u=U( L(U)==min(L(U)) );
S = [S u];
for v = U
if L(u) + w(u,v) < L(v)
L(v) = L(u) + w(u,v);
parent(v) = u;
end
end
end
if parent(V(100)) ~= 0
t = V(100); path = V(100);
while t ~= a
p = parent(t);
path = [p path];
t = p;
end
end
L, path
完
现在卡在
Error using ==> plus
Matrix dimensions must agree.
Error in ==> a1 at 52
if L(u) + w(u,v) < L(v)
L(u)应该是一个数啊,为什么不能加?! 作者: madio 时间: 2013-9-4 20:22