刚入门的萌新一枚,贴一个自己写的代码各位将就着看,有什么不足尽管指出。希望可以一起学习一起进步!
function[dis]=Function_Floyd(e)
n=length(e(1,:)); %获取矩阵长度
%Pone,Ptwo代表第一个点和第二个点,ref代表参考点
for Pone=1:n
for Ptwo=1:n
for ref=1:n
if(e(Pone,Ptwo)~=0&&e(Pone,Ptwo)>e(Pone,ref)+e(ref,Ptwo))
e(Pone,Ptwo)=e(Pone,ref)+e(ref,Ptwo);
end
end
end
end
dis=e;