First version of Floyd-Warshall