Package org.jgrapht.alg
Class KruskalMinimumSpanningTree<V,E>
java.lang.Object
org.jgrapht.alg.KruskalMinimumSpanningTree<V,E>
An implementation of Kruskal's minimum
spanning tree algorithm. If the given graph is connected it computes the
minimum spanning tree, otherwise it computes the minimum spanning forest. The
algorithm runs in time O(E log E). This implementation uses the hashCode and
equals method of the vertices.
- Since:
- Feb 10, 2010
- Author:
- Tom Conerly
-
Constructor Summary
ConstructorsConstructorDescriptionKruskalMinimumSpanningTree(Graph<V, E> graph) Creates and executes a new KruskalMinimumSpanningTree algorithm instance. -
Method Summary
Modifier and TypeMethodDescriptionReturns the edges making up the tree found.doubleReturns the cost of the minimum spanning tree or forest.
-
Constructor Details
-
KruskalMinimumSpanningTree
Creates and executes a new KruskalMinimumSpanningTree algorithm instance. An instance is only good for a single spanning tree; after construction, it can be accessed to retrieve information about the spanning tree found.- Parameters:
graph- the graph to be searched
-
-
Method Details
-
getEdgeSet
Returns the edges making up the tree found.- Returns:
- Set of Edges
-
getSpanningTreeCost
public double getSpanningTreeCost()Returns the cost of the minimum spanning tree or forest.- Returns:
- Cost of the spanning tree
-