public class Kruskal<E extends SpanningTreeEdgeData,V extends UndirectedKruskalVertex<E>>
extends java.lang.Object
Constructor and Description |
---|
Kruskal(UndirectedWeightedEdgeGraph<E,V> graph,
VertexFactory<V> vertexFactory)
Create a new object for generating a minimum spanning tree using Kruskal's
algorithm.
|
Modifier and Type | Method and Description |
---|---|
UndirectedWeightedEdgeGraph<E,V> |
generateTree()
Creates and returns a minimum spanning tree.
|
java.util.Map<V,V> |
getVertexMap()
Returns a map showing which vertex in the spanning tree corresponds to a given
vertex in the original graph.
|
void |
markEdges()
Set edges in minimum spanning tree to BLACK, all other edges are
set to WHITE
|
public Kruskal(UndirectedWeightedEdgeGraph<E,V> graph, VertexFactory<V> vertexFactory)
NullPointerException
will
result if generateTree() is called.graph
- graph for which a minimum spanning tree is to be determinedvertexFactory
- factory method for creating new vertices for the spanning
tree graph that can be generated by calling generateTree()public void markEdges()
public UndirectedWeightedEdgeGraph<E,V> generateTree()
public java.util.Map<V,V> getVertexMap()
java.lang.IllegalStateException
- if this method is called before generateTree(). In this case, the map
has not been created yet.