Implement floyd warshall algorithm