Loading repovive.com/problems/classics/15
Given a weighted directed graph with n vertices and m edges, find the shortest distance from vertex 1 to all other vertices.
Edge weights can be negative. If a vertex is unreachable, output INF. If a vertex is affected by a negative cycle (distance can be −∞), output -INF.
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 -1 0.
0 1 -1 0
3 3 1 2 1 2 3 -1 3 2 -1
For this input, the required output is 0 -INF -INF.
0 -INF -INF
4 2 1 2 5 3 4 3
For this input, the required output is 0 5 INF INF.
0 5 INF INF