Last updated 6 years ago
可有負邊存在
Distk[i]Dist^k[i]Distk[i]: 代表起點到iii的shortest path length,至多經過 kkk個邊。
Dist1Dist^1Dist1為Cost Matrix起點的那一列值,依序求出 Dist2, Dist3...Distn−1Dist^2,\ Dist^3...Dist^{n-1}Dist2, Dist3...Distn−1
Distk[i]=min{Distk−1[i], min{Distk−1[u]+C[u,i]}Dist^k[i]=\min\{Dist^{k-1}[i],\ \min \{Dist^{k-1}[u]+C[u, i]\}Distk[i]=min{Distk−1[i], min{Distk−1[u]+C[u,i]}
e.g.