Floyd-Warshall algorithm (1)