Graph Theory37 sections · 1633 units
Open in Course

Practical Constraints

(When n³ is acceptable)

Floyd-Warshall is O(n3)O(n^3). This is acceptable when n400n \leq 400 or so. If n>500n > 500, n3n^3 becomes too large (over 125125 million operations). Consider Johnson's algorithm or sparse techniques. Floyd-Warshall shines for small to medium graphs or when you need all-pairs distances without complex code.

The simplicity makes it a good choice in competitive programming when nn is small. For production systems, measure carefully.

Space complexity is O(n2)O(n^2) for the distance matrix.