Loading repovive.com/problems/classics/13
Given a weighted directed graph with n vertices and m edges, find the shortest distance from vertex 1 to all other vertices.
All edge weights are non-negative. If a vertex is unreachable from vertex 1, output −1 for that vertex.
4 5 1 2 1 1 3 4 2 3 2 2 4 5 3 4 1
For this input, the required output is 0 1 3 4.
0 1 3 4
3 2 1 2 10 2 3 20
For this input, the required output is 0 10 30.
0 10 30
3 1 1 2 5
For this input, the required output is 0 5 -1.
0 5 -1