Vijay Krishnavanshi
Open Source Developer at KDE
You have to take the input and represent them using adjacency matrix or any of the stated ways of representation.
Keep it simple.
Lets Keep it simple when you follow your intuition what do you see when you are standing on a four way.
For a given list of adjacent vertices of a graph and a chosen vertex v write down in Breadth First Search (BFS) order all the vertices from the connected component of the graph containing v. Assume that the number of vertices of the graph is at most 1000.
Input t [the number of graphs <= 100] Graph: n [1 <= n <= 1000 the number of graph vertices] m[ 1 <=m<= n(n+1) the number of edges] x y [ 1 <= x,y <=n the edges between vertices ]
Output: Listed edges in BFS order with 1 as root.
By Vijay Krishnavanshi