Author: simonetripodi
Date: Sat Dec 10 21:43:31 2011
New Revision: 1212887

URL: http://svn.apache.org/viewvc?rev=1212887&view=rev
Log:
[SANDBOX-344] No WeightedGraph in current method signatures - patch submitted 
by Claudio Squarciarella

Modified:
    
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/SpanningTree.java
    
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableWeightedGraph.java
    
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableWeightedGraph.java
    
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java
    
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java
    
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/Dijkstra.java
    
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/FloydWarshall.java
    
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Boruvka.java
    
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Kruskal.java
    
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Prim.java
    
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/FloydWarshallTestCase.java

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/SpanningTree.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/SpanningTree.java?rev=1212887&r1=1212886&r2=1212887&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/SpanningTree.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/SpanningTree.java
 Sat Dec 10 21:43:31 2011
@@ -27,7 +27,7 @@ package org.apache.commons.graph;
  * @param <WE> the Graph weighted edges type
  */
 public interface SpanningTree<V extends Vertex, WE extends WeightedEdge>
-    extends UndirectedGraph<V, WE>, WeightedGraph<V, WE>
+    extends UndirectedGraph<V, WE>
 {
 
     /**

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableWeightedGraph.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableWeightedGraph.java?rev=1212887&r1=1212886&r2=1212887&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableWeightedGraph.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableWeightedGraph.java
 Sat Dec 10 21:43:31 2011
@@ -21,7 +21,6 @@ package org.apache.commons.graph.model;
 
 import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.WeightedEdge;
-import org.apache.commons.graph.WeightedGraph;
 
 /**
  * A memory-based implementation of a mutable, directed weighted Graph.
@@ -31,7 +30,6 @@ import org.apache.commons.graph.Weighted
  */
 public class DirectedMutableWeightedGraph<V extends Vertex, WE extends 
WeightedEdge>
     extends DirectedMutableGraph<V, WE>
-    implements WeightedGraph<V, WE>
 {
 
 }

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableWeightedGraph.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableWeightedGraph.java?rev=1212887&r1=1212886&r2=1212887&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableWeightedGraph.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableWeightedGraph.java
 Sat Dec 10 21:43:31 2011
@@ -21,7 +21,6 @@ package org.apache.commons.graph.model;
 
 import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.WeightedEdge;
-import org.apache.commons.graph.WeightedGraph;
 
 /**
  * A memory-based implementation of a mutable, undirected weighted Graph.
@@ -31,7 +30,6 @@ import org.apache.commons.graph.Weighted
  */
 public class UndirectedMutableWeightedGraph<V extends Vertex, WE extends 
WeightedEdge>
     extends UndirectedMutableGraph<V, WE>
-    implements WeightedGraph<V, WE>
 {
 
 }

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java?rev=1212887&r1=1212886&r2=1212887&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java
 Sat Dec 10 21:43:31 2011
@@ -24,9 +24,9 @@ import java.util.Queue;
 import java.util.Set;
 
 import org.apache.commons.graph.DirectedGraph;
+import org.apache.commons.graph.Graph;
 import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.WeightedEdge;
-import org.apache.commons.graph.WeightedGraph;
 import org.apache.commons.graph.WeightedPath;
 import org.apache.commons.graph.collections.FibonacciHeap;
 
@@ -55,10 +55,10 @@ public final class AStar
      * @param heuristic the <i>h(x)</i> function
      * @return a path which describes the shortest path, if any, otherwise a 
{@link PathNotFoundException} will be thrown
      */
-    public static <V extends Vertex, WE extends WeightedEdge> WeightedPath<V, 
WE> findShortestPath( WeightedGraph<V, WE> graph,
-                                                                               
                        V start,
-                                                                               
                        V goal,
-                                                                               
                        Heuristic<V> heuristic )
+    public static <V extends Vertex, WE extends WeightedEdge> WeightedPath<V, 
WE> findShortestPath( Graph<V, WE> graph,
+                                                                               
                     V start,
+                                                                               
                     V goal,
+                                                                               
                     Heuristic<V> heuristic )
     {
         // Cost from start along best known path.
         final ShortestDistances<V> gScores = new ShortestDistances<V>();
@@ -92,7 +92,6 @@ public final class AStar
 
             closedSet.add( current );
 
-            @SuppressWarnings( "unchecked" )
             Iterable<V> connected = ( graph instanceof DirectedGraph ) ? ( 
(DirectedGraph<V, WE>) graph ).getOutbound( current )
                                                                        : 
graph.getConnectedVertices( current );
             for ( V v : connected )

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java?rev=1212887&r1=1212886&r2=1212887&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java
 Sat Dec 10 21:43:31 2011
@@ -4,7 +4,6 @@ import org.apache.commons.graph.Directed
 import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.VertexPair;
 import org.apache.commons.graph.WeightedEdge;
-import org.apache.commons.graph.WeightedGraph;
 import org.apache.commons.graph.WeightedPath;
 
 /*
@@ -50,8 +49,8 @@ public final class BellmannFord
      * @param target the shortest path target Vertex
      * @return a path which describes the shortest path, if any, otherwise a 
{@link PathNotFoundException} will be thrown
      */
-    public static <V extends Vertex, WE extends WeightedEdge, G extends 
WeightedGraph<V, WE> & DirectedGraph<V, WE>> AllVertexPairsShortestPath<V, WE> 
findShortestPath( G graph,
-                                                                               
                                                                                
          V source)
+    public static <V extends Vertex, WE extends WeightedEdge, G extends 
DirectedGraph<V, WE>> AllVertexPairsShortestPath<V, WE> findShortestPath( G 
graph,
+                                                                               
                                                                   V source)
     {
         final ShortestDistances<V> shortestDistances = new 
ShortestDistances<V>();
         shortestDistances.setWeight( source, 0D );

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/Dijkstra.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/Dijkstra.java?rev=1212887&r1=1212886&r2=1212887&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/Dijkstra.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/Dijkstra.java
 Sat Dec 10 21:43:31 2011
@@ -26,7 +26,6 @@ import java.util.Set;
 import org.apache.commons.graph.DirectedGraph;
 import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.WeightedEdge;
-import org.apache.commons.graph.WeightedGraph;
 import org.apache.commons.graph.WeightedPath;
 import org.apache.commons.graph.collections.FibonacciHeap;
 
@@ -55,9 +54,9 @@ public final class Dijkstra
      * @return a path which describes the shortest path, if any,
      *         otherwise a {@link PathNotFoundException} will be thrown
      */
-    public static <V extends Vertex, WE extends WeightedEdge, G extends 
WeightedGraph<V, WE> & DirectedGraph<V, WE>> WeightedPath<V, WE> 
findShortestPath( G graph,
-                                                                               
                                                                               
V source,
-                                                                               
                                                                               
V target )
+    public static <V extends Vertex, WE extends WeightedEdge, G extends 
DirectedGraph<V, WE>> WeightedPath<V, WE> findShortestPath( G graph,
+                                                                               
                                                     V source,
+                                                                               
                                                     V target )
     {
         final ShortestDistances<V> shortestDistances = new 
ShortestDistances<V>();
         shortestDistances.setWeight( source, 0D );

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/FloydWarshall.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/FloydWarshall.java?rev=1212887&r1=1212886&r2=1212887&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/FloydWarshall.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/FloydWarshall.java
 Sat Dec 10 21:43:31 2011
@@ -22,11 +22,11 @@ package org.apache.commons.graph.shortes
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.commons.graph.Graph;
 import org.apache.commons.graph.UndirectedGraph;
 import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.VertexPair;
 import org.apache.commons.graph.WeightedEdge;
-import org.apache.commons.graph.WeightedGraph;
 import org.apache.commons.graph.WeightedPath;
 
 /**
@@ -50,7 +50,7 @@ public final class FloydWarshall
      * @param <WE> the Graph weighted edges type
      * @return a data structure which contains all vertex pairs shortest path.
      */
-    public static <V extends Vertex, WE extends WeightedEdge> 
AllVertexPairsShortestPath<V, WE> findAllVertexPairsShortestPath( 
WeightedGraph<V, WE> graph )
+    public static <V extends Vertex, WE extends WeightedEdge> 
AllVertexPairsShortestPath<V, WE> findAllVertexPairsShortestPath( Graph<V, WE> 
graph )
     {
         AllVertexPairsShortestPath<V, WE> shortesPaths = new 
AllVertexPairsShortestPath<V, WE>();
         Map<VertexPair<V>, V> next = new HashMap<VertexPair<V>, V>();
@@ -115,7 +115,7 @@ public final class FloydWarshall
     private static <V extends Vertex, WE extends WeightedEdge> void 
pathReconstruction( PredecessorsList<V, WE> path,
                                                                                
         V source, V target,
                                                                                
         Map<VertexPair<V>, V> next,
-                                                                               
         WeightedGraph<V, WE> graph )
+                                                                               
         Graph<V, WE> graph )
     {
         V k = next.get( new VertexPair<Vertex>( source, target ) );
         if ( k == null )

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Boruvka.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Boruvka.java?rev=1212887&r1=1212886&r2=1212887&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Boruvka.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Boruvka.java
 Sat Dec 10 21:43:31 2011
@@ -22,7 +22,6 @@ package org.apache.commons.graph.spannin
 import org.apache.commons.graph.Graph;
 import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.WeightedEdge;
-import org.apache.commons.graph.WeightedGraph;
 
 /**
  * Boruvka's algorithm is an algorithm for finding a minimum spanning tree in 
a graph
@@ -39,7 +38,7 @@ public final class Boruvka
      * @param graph the Graph for which minimum spanning tree (or forest) has 
to be calculated.
      * @return  the minimum spanning tree (or forest) of the input Graph.
      */
-    public static <V extends Vertex, WE extends WeightedEdge> Graph<V, WE> 
minimumSpanningTree( WeightedGraph<V, WE> graph )
+    public static <V extends Vertex, WE extends WeightedEdge> Graph<V, WE> 
minimumSpanningTree( Graph<V, WE> graph )
     {
         return null;
     }

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Kruskal.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Kruskal.java?rev=1212887&r1=1212886&r2=1212887&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Kruskal.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/Kruskal.java
 Sat Dec 10 21:43:31 2011
@@ -23,11 +23,11 @@ import java.util.HashSet;
 import java.util.PriorityQueue;
 import java.util.Set;
 
+import org.apache.commons.graph.Graph;
 import org.apache.commons.graph.SpanningTree;
 import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.VertexPair;
 import org.apache.commons.graph.WeightedEdge;
-import org.apache.commons.graph.WeightedGraph;
 import org.apache.commons.graph.collections.DisjointSet;
 import org.apache.commons.graph.model.MutableSpanningTree;
 
@@ -46,7 +46,7 @@ public final class Kruskal
      * @param graph the Graph for which minimum spanning tree (or forest) has 
to be calculated.
      * @return  the minimum spanning tree (or forest) of the input Graph.
      */
-    public static <V extends Vertex, WE extends WeightedEdge> SpanningTree<V, 
WE> minimumSpanningTree( WeightedGraph<V, WE> graph )
+    public static <V extends Vertex, WE extends WeightedEdge> SpanningTree<V, 
WE> minimumSpanningTree( Graph<V, WE> graph )
     {
         final Set<V> settledNodes = new HashSet<V>();
 

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=1212887&r1=1212886&r2=1212887&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
 Sat Dec 10 21:43:31 2011
@@ -27,7 +27,6 @@ import org.apache.commons.graph.Spanning
 import org.apache.commons.graph.UndirectedGraph;
 import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.WeightedEdge;
-import org.apache.commons.graph.WeightedGraph;
 
 /**
  * Prim's algorithm is a greedy algorithm that finds a minimum spanning tree 
for a connected weighted undirected graph.
@@ -45,7 +44,7 @@ public final class Prim
      * @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 )
+    public static <V extends Vertex, WE extends WeightedEdge, G extends 
UndirectedGraph<V, WE>> SpanningTree<V, WE> minimumSpanningTree( G graph )
     {
         return minimumSpanningTree( graph, 
graph.getVertices().iterator().next() );
     }
@@ -60,8 +59,8 @@ public final class Prim
      * @param source the Prim's Vertex source
      * @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,
-                                                                               
                                                                                
 V source )
+    public static <V extends Vertex, WE extends WeightedEdge, G extends 
UndirectedGraph<V, WE>> SpanningTree<V, WE> minimumSpanningTree( G graph,
+                                                                               
                                                          V source )
     {
         final ShortestEdges<V, WE> shortesEdges = new ShortestEdges<V, WE>( 
graph, source );
 

Modified: 
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/FloydWarshallTestCase.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/FloydWarshallTestCase.java?rev=1212887&r1=1212886&r2=1212887&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/FloydWarshallTestCase.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/FloydWarshallTestCase.java
 Sat Dec 10 21:43:31 2011
@@ -23,9 +23,9 @@ import static junit.framework.Assert.ass
 import static junit.framework.Assert.fail;
 import static 
org.apache.commons.graph.shortestpath.FloydWarshall.findAllVertexPairsShortestPath;
 
+import org.apache.commons.graph.Graph;
 import org.apache.commons.graph.MutableGraph;
 import org.apache.commons.graph.UndirectedGraph;
-import org.apache.commons.graph.WeightedGraph;
 import org.apache.commons.graph.WeightedPath;
 import org.apache.commons.graph.model.BaseLabeledVertex;
 import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
@@ -51,8 +51,7 @@ public class FloydWarshallTestCase
         findShortestPathAndVerify( new 
DirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge>() );
     }
 
-    @SuppressWarnings( "unchecked" )
-    private void findShortestPathAndVerify( WeightedGraph<BaseLabeledVertex, 
BaseLabeledWeightedEdge> weighted )
+    private void findShortestPathAndVerify( Graph<BaseLabeledVertex, 
BaseLabeledWeightedEdge> weighted )
     {
         // mutable by definition, generic types driven by input graph
         MutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge> mutable =


Reply via email to