[50 marks] minWeightTree: the object associated with the method is a WeightedEdgeList that has already been sorted by weight. The tasks of sorting by weight and finding the minimum weight tree have been separated so that you can get part marks if one of the two methods works properly but the other one does not.
If the graph is connected, the method returns a WeightedEdgeList that contains the edges in a minimum weight spanning tree. If the graph is not connected, the edges returned give minimum weight spanning trees for each of the components of the graph. The tree edges should be removed from the WeightedEdgeList that is the object associated with the method. This means that when the method returns, the original object contains just the non-tree edges (the chords).
The algorithm you should implement for this question is:
For each of the edges e= (u, v) in the original WeightedEdgeList:
If u and v are not in the same component
Remove the node with e from the WeightedEdgeList
and add it to the end of the list of tree edges.
endif
end for
You should use the methods in the class UnionFind to maintain information about the connected components.
这个java函数怎么写