F1201-lecture1-180320-bfs-for-a-graphs

easy
  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 a, as the source vertex of the graph.
3. In breadth first search you have to traverse all the vertices that are reachable from a given source vertex ,in such a fashion that all the vertices are visited only once 
   and the vertices will be printed in level wise.(For example, the vertices which are an edge away from the source is printed first, the vertices which are two edges away, then three and so on... i.e. printed in increasing radius pattern).
                               
                               

Input Format

1.First line consist of a integer value a (vertex1 - the point from where we have to start bfs traversal).

Output Format

void

Constraints

1. 0<=a,b<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
3 via 03 @40
1 via 01 @10
2 via 032 @50
4 via 034 @42
5 via 0345 @45
6 via 0346 @50
Previous
F1201-lecture1-180320-hamiltonian-path-and-cycle
Next
Lu1203_160320_ngol

Related Questions