Floyd-Warshall computes distances between every pair of nodes in . Use it when N ≤ and you need all-pairs distances. If N = , operations.
Too slow. Run Dijkstra N times instead if weights are non-negative. Floyd-Warshall also works with negative edges and detects negative cycles. Check the diagonal after running it: if dist[i][i] < 0 for any , a negative cycle exists that passes through node .