Graph Theory37 sections · 1633 units
Open in Course

Common Mistakes

(Mistakes to avoid)

Mistake 11: Looping ii, jj, kk instead of kk, ii, jj. This breaks the DP dependency and gives wrong answers. Mistake 22: Forgetting dist[i][i] = 0. This makes the algorithm think the distance from ii to itself is infinity.

Mistake 33: Not checking for negative cycles before using distdist values. If dist[i][i] < 0, the entire distance matrix is invalid. These are the most common errors when implementing Floyd-Warshall.