class kruskalelem implements comparable private int vwweightpublic kruskalelem(int inweightint invint inwweight inweightv invw inwpublic int (return vpublic int (return wpublic int key(return weightpublic int compareto(kruskalelem thatif (weight that key()return - else if (weight =that key()return else return static void kruskal(graph /kruskal' mst algorithm parptrtree new parptrtree( ())/equivalence array kruskalelem[ new kruskalelem[ ()]/minheap array int edgecnt /count of edges for (int = < () ++/put edges in the array for (int first( ) () next(iw) [edgecnt++new kruskalelem( weight(iw)iw)minheap new minheap(eedgecntedgecnt)int nummst ()/initially classes for (int = nummst> ++/combine equiv classes kruskalelem temp removemin()/next cheapest int temp ()int temp ()if ( differ(vu)/if in different classes union(vu)/combine equiv classes addedgetomst(vu)/add this edge to mst nummst--/one less mst figure an implementation for kruskal' algorithm wright pseudocode algorithm to create dfs tree for an undirectedconnected graph starting at specified vertex show the bfs tree for the graph of figure starting at vertex wright pseudocode algorithm to create bfs tree for an undirectedconnected graph starting at specified vertex the bfs topological sort algorithm can report the existence of cycle if one is encountered modify this algorithm to print the vertices possibly appearing in cycles (if there are any cycles