1.You will be given an graph represented in form of ArrayList<ArrayList<edge>>, where edge is a user defined class (a type) which contains three Integer data members:
1st : v1 (denotes) vertex1.
2nd : v2 (denotes) vertex2.
3rd : wt (denotes the weight of edge b/w v1 and v2).
(we have constructed this representation of graph in 1st question)
2. You will be given an integer value a, as a source vertex of the graph.
3. Given a graph and a source vertex in the graph, find shortest paths from source to all vertices in the given graph.
Input Format
1.First line consist of an integer a(vertex1).
Output Format
void
Constraints
1. 0<=a<graphs size
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
0
Output
0 via 0 @ 0 1 via 01 @ 10 2 via 012 @ 20 3 via 0123 @ 30 4 via 01234 @ 32 5 via 012345 @ 35 6 via 0123456 @ 38