Update Floyd–Warshall algorithm