graphlab.library.algorithms.spanningtree
Class Prim<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
java.lang.Object
graphlab.library.algorithms.Algorithm
graphlab.library.algorithms.spanningtree.Prim<VertexType,EdgeType>
- All Implemented Interfaces:
- AlgorithmInterface, AutomatedAlgorithm
- Direct Known Subclasses:
- PrimAnim
public class Prim<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
- extends Algorithm
- implements AutomatedAlgorithm
Implementation of Prim algorithm to find minimum spanning tree.
The output of this method is a new independent graph representing
the spanning tree.
- Author:
- Omid Aladini
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Prim
public Prim(BaseGraph<VertexType,EdgeType> graph,
EdgeVertexCopier<VertexType,EdgeType> gc)
- Constructor of the Prim algorithm.
- Parameters:
graph
- Graph the algorithm is going to find it's minimum spanning tree.gc
- Reference to a GraphConverter object which is responsible for duplication
of the graph elements, because graph edges and vertices are going to be
copied to the newly created spanning tree.
findMinimumSpanningTree
public Pair<java.util.Vector<VertexType>,java.util.Vector<EdgeType>> findMinimumSpanningTree(VertexType v,
java.util.Comparator<EdgeType> comparator)
throws InvalidGraphException,
InvalidVertexException
- Finds minimum spanning tree starting at vertex v. Note that if
your graph is not connected, the algorithm falls in an infinite loop
it's the caller's task to check connectivity.
- Parameters:
v
- Start vertex of Prim algorithm.
- Returns:
- The spanning tree graph.
- Throws:
InvalidGraphException
- if the supplied vertex is invalid.
InvalidVertexException
findMinimumSpanningTree
public Pair<java.util.Vector<VertexType>,java.util.Vector<EdgeType>> findMinimumSpanningTree(VertexType v)
throws InvalidGraphException,
InvalidVertexException
- Finds minimum spanning tree starting at vertex v. Note that if
your graph is not connected, the algorithm falls in an infinite loop
it's the caller's task to check connectivity. Default comparator
which compares weight parameter of the graph is used.
- Parameters:
v
- Start vertex of Prim algorithm.
- Returns:
- The spanning tree graph.
- Throws:
InvalidGraphException
- if the supplied vertex is invalid.
InvalidVertexException
doAlgorithm
public void doAlgorithm()
- Specified by:
doAlgorithm
in interface AutomatedAlgorithm