for k = 1 to n do
for i = 1 to n do
for j = 1 to n do
if (Di,j>Di,k + Dk,j) then
Di,j = Di,k + Dk,j;
for i = 1 to n do
for j = 1 to n do
if (Di,j>Di,k + Dk,j) then
Di,j = Di,k + Dk,j;
参考:http://zh.wikipedia.org/zh-cn/Floyd-Warshall%E7%AE%97%E6%B3%95
参考:http://zh.wikipedia.org/zh-cn/Floyd-Warshall%E7%AE%97%E6%B3%95