Loading repovive.com/problems/classics/11
Given an unweighted undirected graph with n vertices and m edges, find the shortest distance from vertex 1 to all other vertices.
If a vertex is unreachable from vertex 1, output −1 for that vertex.
4 4 1 2 2 3 3 4 1 3
For this input, the required output is 0 1 1 2.
0 1 1 2
3 2 1 2 2 3
For this input, the required output is 0 1 2.
0 1 2
4 2 1 2 3 4
For this input, the required output is 0 1 -1 -1.
0 1 -1 -1