Loading repovive.com/problems/classics/16
Given a weighted directed graph with n vertices and m edges, find the shortest distance between every pair of vertices.
Edge weights are non-negative. If there is no path from vertex i to vertex j, the distance is −1.
4 6 1 2 3 1 3 6 2 3 2 2 4 5 3 4 1 4 1 2
For this input, the required output is 0 3 5 6 5 0 2 3 3 6 0 1 2 5 7 0.
0 3 5 6 5 0 2 3 3 6 0 1 2 5 7 0
3 3 1 2 1 2 3 2 1 3 5
For this input, the required output is 0 1 3 -1 0 2 -1 -1 0.
0 1 3 -1 0 2 -1 -1 0
2 0
For this input, the required output is 0 -1 -1 0.
0 -1 -1 0