Floyd-Warshall algorithm for all pairs shortest paths