8.1. Abstraction
This section discusses spanning trees in a graph.
A spanning tree in a graph is a tree that contains all vertices in the graphs as its nodes. A minimum spanning tree is a spanning tree whose sum of all edge weights is the minimum among all the other spanning trees in the graph.
Can a graph have more than one minimum spanning tree?
Let us define the class under the package:
L1: inherits the interface.
L2: contains all edges in this spanning tree.
We then define getters and setters:
L3: the size of the spanning tree is determined by the number of edges.
Finally, we override the compareTo() method that makes the comparison to another spanning tree by the total weight:
Let us create the interface that is inherited by all minimum spanning tree algorithms:
L2: an abstract method that takes a graph and returns a minimum spanning tree.