I am looking at the Floyd-Warshall algorithm.
let dist be a |V| × |V| array of minimum distances initialized to ∞ (infinity)
// part 1
for each vertex v
dist[v][v] ← 0
// part 2
for each edge (u,v)
dist[u][v] ← w(u,v) // the weight of the edge (u,v)
// part 3
for k from 1 to |V|
for i from 1 to |V|
for j from 1 to |V|
if dist[i][k] + dist[k][j] < dist[i][j] then
dist[i][j] ← dist[i][k] + dist[k][j]
In the page, it says the Floyd–Warshall algorithm assumes that there are no negative cycles
. So my question is what will happen if the entry graph hides negative circle. Will the output dist
represents another graph hiding negative circle? Does not part 1
invalid this?