Author: simonetripodi
Date: Tue Jul  5 18:24:43 2011
New Revision: 1143158

URL: http://svn.apache.org/viewvc?rev=1143158&view=rev
Log:
added a Prim's algorithm method that select the Vertex source from the input 
Graph vertices

Modified:
    
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Prim.java

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Prim.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Prim.java?rev=1143158&r1=1143157&r2=1143158&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Prim.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Prim.java
 Tue Jul  5 18:24:43 2011
@@ -36,7 +36,22 @@ public final class Prim
 {
 
     /**
-     * Calculates the minimum spanning tree (or forest) of the input Graph.
+     * Calculates the minimum spanning tree of the input Graph,
+     * selecting the Vertex source from the input Graph.
+     *
+     * @param <V> the Graph vertices type.
+     * @param <WE> the Graph weighted edges type.
+     * @param <G> the weighted-undirected input graph type
+     * @param graph the Graph for which minimum spanning tree has to be 
calculated.
+     * @return the minimum spanning tree of the input Graph.
+     */
+    public static <V extends Vertex, WE extends WeightedEdge, G extends 
WeightedGraph<V, WE> & UndirectedGraph<V, WE>> SpanningTree<V, WE> 
minimumSpanningTree( G graph )
+    {
+        return minimumSpanningTree( graph, 
graph.getVertices().iterator().next() );
+    }
+
+    /**
+     * Calculates the minimum spanning tree (or forest) of the input Graph, 
given a known source.
      *
      * @param <V> the Graph vertices type.
      * @param <WE> the Graph weighted edges type.


Reply via email to