commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1234551 - in /commons/sandbox/graph/trunk/src: changes/ main/java/org/apache/commons/graph/ main/java/org/apache/commons/graph/builder/ main/java/org/apache/commons/graph/model/ main/java/org/apache/commons/graph/spanning/ test/java/org/ap...
Date Sun, 22 Jan 2012 17:11:32 GMT
Author: simonetripodi
Date: Sun Jan 22 17:11:31 2012
New Revision: 1234551

URL: http://svn.apache.org/viewvc?rev=1234551&view=rev
Log:
[SANDBOX-364] Adding generic weight type to model - patch submitted by Claudio Squarcella

Modified:
    commons/sandbox/graph/trunk/src/changes/changes.xml
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/WeightedEdge.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/builder/GraphBuilder.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/spanning/Kruskal.java
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/builder/GraphBuilderTestCase.java
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/AStarTestCase.java
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/BellmannFordTestCase.java
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/DijkstraTestCase.java
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/FloydWarshallTestCase.java
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java

Modified: commons/sandbox/graph/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/changes/changes.xml?rev=1234551&r1=1234550&r2=1234551&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/changes/changes.xml (original)
+++ commons/sandbox/graph/trunk/src/changes/changes.xml Sun Jan 22 17:11:31 2012
@@ -23,6 +23,9 @@
   </properties>
   <body>
   <release version="0.1" date="201?-??-??" description="First release.">
+    <action dev="simonetripodi" type="update" issue="SANDBOX-364" due-to="Claudio Squarcella">
+      Adding generic weight type to model
+    </action>
     <action dev="simonetripodi" type="update" issue="SANDBOX-361">
       Add fluent APIs to build mutable Graphes
     </action>

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/WeightedEdge.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/WeightedEdge.java?rev=1234551&r1=1234550&r2=1234551&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/WeightedEdge.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/WeightedEdge.java Sun Jan 22 17:11:31 2012
@@ -26,7 +26,7 @@ package org.apache.commons.graph;
  * @param <W> the weight type
  */
 public interface WeightedEdge<W>
-    extends Edge, Weighted<W>, Comparable<WeightedEdge<W>>
+    extends Edge, Weighted<W>
 {
 
 }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/builder/GraphBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/builder/GraphBuilder.java?rev=1234551&r1=1234550&r2=1234551&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/builder/GraphBuilder.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/builder/GraphBuilder.java Sun Jan 22 17:11:31 2012
@@ -38,9 +38,9 @@ public final class GraphBuilder<V extend
         return populate( new DirectedMutableGraph<V, E>() ).withConnections( graphConnection );
     }
 
-    public static <V extends Vertex, WE extends WeightedEdge<Double>> DirectedMutableWeightedGraph<V, WE> newDirectedMutableWeightedGraph( GraphConnection<V, WE> graphConnection )
+    public static <V extends Vertex, WE extends WeightedEdge<W>, W> DirectedMutableWeightedGraph<V, WE, W> newDirectedMutableWeightedGraph( GraphConnection<V, WE> graphConnection )
     {
-        return populate( new DirectedMutableWeightedGraph<V, WE>() ).withConnections( graphConnection );
+        return populate( new DirectedMutableWeightedGraph<V, WE, W>() ).withConnections( graphConnection );
     }
 
     public static <V extends Vertex, E extends Edge> UndirectedMutableGraph<V, E> newUndirectedMutableGraph( GraphConnection<V, E> graphConnection )
@@ -48,9 +48,9 @@ public final class GraphBuilder<V extend
         return populate( new UndirectedMutableGraph<V, E>() ).withConnections( graphConnection );
     }
 
-    public static <V extends Vertex, WE extends WeightedEdge<Double>> UndirectedMutableWeightedGraph<V, WE> newUndirectedMutableWeightedGraph( GraphConnection<V, WE> graphConnection )
+    public static <V extends Vertex, WE extends WeightedEdge<W>, W> UndirectedMutableWeightedGraph<V, WE, W> newUndirectedMutableWeightedGraph( GraphConnection<V, WE> graphConnection )
     {
-        return populate( new UndirectedMutableWeightedGraph<V, WE>() ).withConnections( graphConnection );
+        return populate( new UndirectedMutableWeightedGraph<V, WE, W>() ).withConnections( graphConnection );
     }
 
     public static <V extends Vertex, E extends Edge, G extends MutableGraph<V, E>> LinkedConnectionBuilder<V, E, G> populate( G graph )

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=1234551&r1=1234550&r2=1234551&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 Sun Jan 22 17:11:31 2012
@@ -28,7 +28,7 @@ import org.apache.commons.graph.Weighted
  * @param <V> the Graph vertices type
  * @param <WE> the WeightedEdge edges type
  */
-public class DirectedMutableWeightedGraph<V extends Vertex, WE extends WeightedEdge<Double>>
+public class DirectedMutableWeightedGraph<V extends Vertex, WE extends WeightedEdge<W>, W>
     extends DirectedMutableGraph<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=1234551&r1=1234550&r2=1234551&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 Sun Jan 22 17:11:31 2012
@@ -28,7 +28,7 @@ import org.apache.commons.graph.Weighted
  * @param <V> the Graph vertices type
  * @param <WE> the WeightedEdge edges type
  */
-public class UndirectedMutableWeightedGraph<V extends Vertex, WE extends WeightedEdge<Double>>
+public class UndirectedMutableWeightedGraph<V extends Vertex, WE extends WeightedEdge<W>, W>
     extends UndirectedMutableGraph<V, WE>
 {
 

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=1234551&r1=1234550&r2=1234551&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 Sun Jan 22 17:11:31 2012
@@ -19,6 +19,7 @@ package org.apache.commons.graph.spannin
  * under the License.
  */
 
+import java.util.Comparator;
 import java.util.HashSet;
 import java.util.PriorityQueue;
 import java.util.Set;
@@ -51,11 +52,12 @@ public final class Kruskal
      * @return  the minimum spanning tree (or forest) of the input Graph
      */
     public static <V extends Vertex, W, WE extends WeightedEdge<W>> SpanningTree<V, WE, W> minimumSpanningTree( Graph<V, WE> graph,
-                                                                                                                OrderedMonoid<W> orderedMonoid)
+                                                                                                                final OrderedMonoid<W> orderedMonoid)
     {
         final Set<V> settledNodes = new HashSet<V>();
 
-        final PriorityQueue<WE> orderedEdges = new PriorityQueue<WE>( graph.getSize() );
+        final PriorityQueue<WE> orderedEdges = new PriorityQueue<WE>( graph.getSize(),
+                                                                      new WeightedEdgesComparator<W, WE>( orderedMonoid ) );
 
         for ( WE edge : graph.getEdges() )
         {
@@ -92,7 +94,7 @@ public final class Kruskal
 
         return spanningTree;
     }
-    
+
     /**
      * Calculates the minimum spanning tree (or forest) of the input Graph.
      *
@@ -106,4 +108,21 @@ public final class Kruskal
         return minimumSpanningTree( graph, new DoubleWeight() );
     }
 
+    private static class WeightedEdgesComparator<W, WE extends WeightedEdge<W>> implements Comparator<WE>
+    {
+
+        private final OrderedMonoid<W> orderedMonoid;
+
+        public WeightedEdgesComparator( OrderedMonoid<W> orderedMonoid )
+        {
+            this.orderedMonoid = orderedMonoid;
+        }
+
+        public int compare( WE o1, WE o2 )
+        {
+            return orderedMonoid.compare( o1.getWeight(), o2.getWeight() );
+        }
+
+    }
+
 }

Modified: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/builder/GraphBuilderTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/builder/GraphBuilderTestCase.java?rev=1234551&r1=1234550&r2=1234551&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/builder/GraphBuilderTestCase.java (original)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/builder/GraphBuilderTestCase.java Sun Jan 22 17:11:31 2012
@@ -34,8 +34,8 @@ public final class GraphBuilderTestCase
     @Test
     public void verifyProducedGraphesAreEquals()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge> expected =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge>();
+        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> expected =
+            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>();
 
         // building Graph with traditional APIs...
 
@@ -55,20 +55,20 @@ public final class GraphBuilderTestCase
         expected.addVertex( e );
         expected.addVertex( goal );
 
-        expected.addEdge( start, new BaseLabeledWeightedEdge( "start <-> a", 1.5D ), a );
-        expected.addEdge( start, new BaseLabeledWeightedEdge( "start <-> d", 2D ), d );
+        expected.addEdge( start, new BaseLabeledWeightedEdge<Double>( "start <-> a", 1.5D ), a );
+        expected.addEdge( start, new BaseLabeledWeightedEdge<Double>( "start <-> d", 2D ), d );
 
-        expected.addEdge( a, new BaseLabeledWeightedEdge( "a <-> b", 2D ), b );
-        expected.addEdge( b, new BaseLabeledWeightedEdge( "b <-> c", 3D ), c );
-        expected.addEdge( c, new BaseLabeledWeightedEdge( "c <-> goal", 3D ), goal );
+        expected.addEdge( a, new BaseLabeledWeightedEdge<Double>( "a <-> b", 2D ), b );
+        expected.addEdge( b, new BaseLabeledWeightedEdge<Double>( "b <-> c", 3D ), c );
+        expected.addEdge( c, new BaseLabeledWeightedEdge<Double>( "c <-> goal", 3D ), goal );
 
-        expected.addEdge( d, new BaseLabeledWeightedEdge( "d <-> e", 3D ), e );
-        expected.addEdge( e, new BaseLabeledWeightedEdge( "e <-> goal", 2D ), goal );
+        expected.addEdge( d, new BaseLabeledWeightedEdge<Double>( "d <-> e", 3D ), e );
+        expected.addEdge( e, new BaseLabeledWeightedEdge<Double>( "e <-> goal", 2D ), goal );
 
         // ... and using the EDSL :)
 
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge> actual =
-        newUndirectedMutableWeightedGraph( new AbstractGraphConnection<BaseLabeledVertex, BaseLabeledWeightedEdge>()
+        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> actual =
+        newUndirectedMutableWeightedGraph( new AbstractGraphConnection<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>()
         {
 
             public void connect()
@@ -81,15 +81,15 @@ public final class GraphBuilderTestCase
                 BaseLabeledVertex e = addVertex( new BaseLabeledVertex( "e" ) );
                 BaseLabeledVertex goal = addVertex( new BaseLabeledVertex( "goal" ) );
 
-                addEdge( new BaseLabeledWeightedEdge( "start <-> a", 1.5D ) ).from( start ).to( a );
-                addEdge( new BaseLabeledWeightedEdge( "start <-> d", 2D ) ).from( start ).to( d );
+                addEdge( new BaseLabeledWeightedEdge<Double>( "start <-> a", 1.5D ) ).from( start ).to( a );
+                addEdge( new BaseLabeledWeightedEdge<Double>( "start <-> d", 2D ) ).from( start ).to( d );
 
-                addEdge( new BaseLabeledWeightedEdge( "a <-> b", 2D ) ).from( a ).to( b );
-                addEdge( new BaseLabeledWeightedEdge( "b <-> c", 3D ) ).from( b ).to( c );
-                addEdge( new BaseLabeledWeightedEdge( "c <-> goal", 3D ) ).from( c ).to( goal );
+                addEdge( new BaseLabeledWeightedEdge<Double>( "a <-> b", 2D ) ).from( a ).to( b );
+                addEdge( new BaseLabeledWeightedEdge<Double>( "b <-> c", 3D ) ).from( b ).to( c );
+                addEdge( new BaseLabeledWeightedEdge<Double>( "c <-> goal", 3D ) ).from( c ).to( goal );
 
-                addEdge( new BaseLabeledWeightedEdge( "d <-> e", 3D ) ).from( d ).to( e );
-                addEdge( new BaseLabeledWeightedEdge( "e <-> goal", 2D ) ).from( e ).to( goal );
+                addEdge( new BaseLabeledWeightedEdge<Double>( "d <-> e", 3D ) ).from( d ).to( e );
+                addEdge( new BaseLabeledWeightedEdge<Double>( "e <-> goal", 2D ) ).from( e ).to( goal );
             }
 
         } );

Modified: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java?rev=1234551&r1=1234550&r2=1234551&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java (original)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java Sun Jan 22 17:11:31 2012
@@ -27,14 +27,14 @@ import org.apache.commons.graph.Weighted
 /**
  *
  */
-public class BaseLabeledWeightedEdge
+public class BaseLabeledWeightedEdge<W>
     extends BaseLabeledEdge
-    implements WeightedEdge<Double>
+    implements WeightedEdge<W>
 {
 
-    private final Double weight;
+    private final W weight;
 
-    public BaseLabeledWeightedEdge( String label, Double weight )
+    public BaseLabeledWeightedEdge( String label, W weight )
     {
         super( label );
         this.weight = checkNotNull( weight, "Argument 'weight' must not be null" );
@@ -43,15 +43,7 @@ public class BaseLabeledWeightedEdge
     /**
      * {@inheritDoc}
      */
-    public int compareTo( WeightedEdge<Double> other )
-    {
-        return weight.compareTo( other.getWeight() );
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Double getWeight()
+    public W getWeight()
     {
         return weight;
     }
@@ -88,8 +80,8 @@ public class BaseLabeledWeightedEdge
         {
             return false;
         }
-
-        BaseLabeledWeightedEdge other = (BaseLabeledWeightedEdge) obj;
+        @SuppressWarnings( "unchecked" )
+        BaseLabeledWeightedEdge<W> other = (BaseLabeledWeightedEdge<W>) obj;
         if ( !weight.equals( other.getWeight() ) )
         {
             return false;

Modified: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/AStarTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/AStarTestCase.java?rev=1234551&r1=1234550&r2=1234551&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/AStarTestCase.java (original)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/AStarTestCase.java Sun Jan 22 17:11:31 2012
@@ -43,8 +43,8 @@ public final class AStarTestCase
     @Test
     public void findShortestPathAndVerify()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge> graph =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge>();
+        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> graph =
+            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>();
 
         // building Graph
 
@@ -64,15 +64,15 @@ public final class AStarTestCase
         graph.addVertex( e );
         graph.addVertex( goal );
 
-        graph.addEdge( start, new BaseLabeledWeightedEdge( "start <-> a", 1.5D ), a );
-        graph.addEdge( start, new BaseLabeledWeightedEdge( "start <-> d", 2D ), d );
+        graph.addEdge( start, new BaseLabeledWeightedEdge<Double>( "start <-> a", 1.5D ), a );
+        graph.addEdge( start, new BaseLabeledWeightedEdge<Double>( "start <-> d", 2D ), d );
 
-        graph.addEdge( a, new BaseLabeledWeightedEdge( "a <-> b", 2D ), b );
-        graph.addEdge( b, new BaseLabeledWeightedEdge( "b <-> c", 3D ), c );
-        graph.addEdge( c, new BaseLabeledWeightedEdge( "c <-> goal", 3D ), goal );
+        graph.addEdge( a, new BaseLabeledWeightedEdge<Double>( "a <-> b", 2D ), b );
+        graph.addEdge( b, new BaseLabeledWeightedEdge<Double>( "b <-> c", 3D ), c );
+        graph.addEdge( c, new BaseLabeledWeightedEdge<Double>( "c <-> goal", 3D ), goal );
 
-        graph.addEdge( d, new BaseLabeledWeightedEdge( "d <-> e", 3D ), e );
-        graph.addEdge( e, new BaseLabeledWeightedEdge( "e <-> goal", 2D ), goal );
+        graph.addEdge( d, new BaseLabeledWeightedEdge<Double>( "d <-> e", 3D ), e );
+        graph.addEdge( e, new BaseLabeledWeightedEdge<Double>( "e <-> goal", 2D ), goal );
 
         // euristics
 
@@ -96,17 +96,17 @@ public final class AStarTestCase
 
         // expected path
 
-        InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> expected =
-            new InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge, Double>( start, goal, new DoubleWeight() );
+        InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> expected =
+            new InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>( start, goal, new DoubleWeight() );
 
-        expected.addConnectionInTail( start, new BaseLabeledWeightedEdge( "start <-> a", 1.5D ), a );
-        expected.addConnectionInTail( a, new BaseLabeledWeightedEdge( "a <-> b", 2D ), b );
-        expected.addConnectionInTail( b, new BaseLabeledWeightedEdge( "b <-> c", 3D ), c );
-        expected.addConnectionInTail( c, new BaseLabeledWeightedEdge( "c <-> goal", 3D ), goal );
+        expected.addConnectionInTail( start, new BaseLabeledWeightedEdge<Double>( "start <-> a", 1.5D ), a );
+        expected.addConnectionInTail( a, new BaseLabeledWeightedEdge<Double>( "a <-> b", 2D ), b );
+        expected.addConnectionInTail( b, new BaseLabeledWeightedEdge<Double>( "b <-> c", 3D ), c );
+        expected.addConnectionInTail( c, new BaseLabeledWeightedEdge<Double>( "c <-> goal", 3D ), goal );
 
         // actual path
 
-        Path<BaseLabeledVertex, BaseLabeledWeightedEdge> actual = findShortestPath( graph, start, goal, heuristic );
+        Path<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>> actual = findShortestPath( graph, start, goal, heuristic );
 
         // assert!
 

Modified: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/BellmannFordTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/BellmannFordTestCase.java?rev=1234551&r1=1234550&r2=1234551&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/BellmannFordTestCase.java (original)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/BellmannFordTestCase.java Sun Jan 22 17:11:31 2012
@@ -41,8 +41,8 @@ public final class BellmannFordTestCase
     public void findShortestPathAndVerify()
     {
         // the input graph
-        DirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge> graph =
-            new DirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge>();
+        DirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> graph =
+            new DirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>();
 
         BaseLabeledVertex one = new BaseLabeledVertex( "1" );
         BaseLabeledVertex two = new BaseLabeledVertex( "2" );
@@ -56,32 +56,32 @@ public final class BellmannFordTestCase
         graph.addVertex( four );
         graph.addVertex( five );
 
-        graph.addEdge( one, new BaseLabeledWeightedEdge( "1 -> 2", 6D ), two );
-        graph.addEdge( one, new BaseLabeledWeightedEdge( "1 -> 4", 7D ), four );
+        graph.addEdge( one, new BaseLabeledWeightedEdge<Double>( "1 -> 2", 6D ), two );
+        graph.addEdge( one, new BaseLabeledWeightedEdge<Double>( "1 -> 4", 7D ), four );
 
-        graph.addEdge( two, new BaseLabeledWeightedEdge( "2 -> 3", 5D ), three );
-        graph.addEdge( two, new BaseLabeledWeightedEdge( "2 -> 5", -4D ), five );
-        graph.addEdge( two, new BaseLabeledWeightedEdge( "2 -> 4", 8D ), four );
+        graph.addEdge( two, new BaseLabeledWeightedEdge<Double>( "2 -> 3", 5D ), three );
+        graph.addEdge( two, new BaseLabeledWeightedEdge<Double>( "2 -> 5", -4D ), five );
+        graph.addEdge( two, new BaseLabeledWeightedEdge<Double>( "2 -> 4", 8D ), four );
 
-        graph.addEdge( three, new BaseLabeledWeightedEdge( "3 -> 2", -2D ), two );
+        graph.addEdge( three, new BaseLabeledWeightedEdge<Double>( "3 -> 2", -2D ), two );
 
-        graph.addEdge( four, new BaseLabeledWeightedEdge( "4 -> 3", -3D ), three );
-        graph.addEdge( four, new BaseLabeledWeightedEdge( "4 -> 5", 9D ), five );
+        graph.addEdge( four, new BaseLabeledWeightedEdge<Double>( "4 -> 3", -3D ), three );
+        graph.addEdge( four, new BaseLabeledWeightedEdge<Double>( "4 -> 5", 9D ), five );
 
-        graph.addEdge( five, new BaseLabeledWeightedEdge( "5 -> 3", 7D ), three );
-        graph.addEdge( five, new BaseLabeledWeightedEdge( "5 -> 1", 2D ), one );
+        graph.addEdge( five, new BaseLabeledWeightedEdge<Double>( "5 -> 3", 7D ), three );
+        graph.addEdge( five, new BaseLabeledWeightedEdge<Double>( "5 -> 1", 2D ), one );
 
         // the expected weighted path
-        InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> expected =
-            new InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge, Double>( one, three, new DoubleWeight() );
-        expected.addConnectionInTail( one, new BaseLabeledWeightedEdge( "1 -> 4", 7D ), four );
-        expected.addConnectionInTail( four, new BaseLabeledWeightedEdge( "4 -> 3", -3D ), three );
+        InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> expected =
+            new InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>( one, three, new DoubleWeight() );
+        expected.addConnectionInTail( one, new BaseLabeledWeightedEdge<Double>( "1 -> 4", 7D ), four );
+        expected.addConnectionInTail( four, new BaseLabeledWeightedEdge<Double>( "4 -> 3", -3D ), three );
 
         // the actual weighted path
-        AllVertexPairsShortestPath<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> allVertexPairsShortestPath =
+        AllVertexPairsShortestPath<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> allVertexPairsShortestPath =
             findShortestPath( graph, one );
 
-        WeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> actual =
+        WeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> actual =
             allVertexPairsShortestPath.findShortestPath( one, three );
         assertEquals( expected, actual );
     }

Modified: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/DijkstraTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/DijkstraTestCase.java?rev=1234551&r1=1234550&r2=1234551&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/DijkstraTestCase.java (original)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/DijkstraTestCase.java Sun Jan 22 17:11:31 2012
@@ -40,8 +40,8 @@ public final class DijkstraTestCase
     @Test
     public void findShortestPathAndVerify()
     {
-        DirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge> graph =
-            new DirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge>();
+        DirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> graph =
+            new DirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>();
 
         // building Graph
 
@@ -59,31 +59,31 @@ public final class DijkstraTestCase
         graph.addVertex( five );
         graph.addVertex( six );
 
-        graph.addEdge( one, new BaseLabeledWeightedEdge( "1 -> 6", 14D ), six );
-        graph.addEdge( one, new BaseLabeledWeightedEdge( "1 -> 3", 9D ), three );
-        graph.addEdge( one, new BaseLabeledWeightedEdge( "1 -> 2", 7D ), two );
+        graph.addEdge( one, new BaseLabeledWeightedEdge<Double>( "1 -> 6", 14D ), six );
+        graph.addEdge( one, new BaseLabeledWeightedEdge<Double>( "1 -> 3", 9D ), three );
+        graph.addEdge( one, new BaseLabeledWeightedEdge<Double>( "1 -> 2", 7D ), two );
 
-        graph.addEdge( two, new BaseLabeledWeightedEdge( "2 -> 3", 10D ), three );
-        graph.addEdge( two, new BaseLabeledWeightedEdge( "2 -> 4", 15D ), four );
+        graph.addEdge( two, new BaseLabeledWeightedEdge<Double>( "2 -> 3", 10D ), three );
+        graph.addEdge( two, new BaseLabeledWeightedEdge<Double>( "2 -> 4", 15D ), four );
 
-        graph.addEdge( three, new BaseLabeledWeightedEdge( "3 -> 6", 2D ), six );
-        graph.addEdge( three, new BaseLabeledWeightedEdge( "3 -> 4", 11D ), four );
+        graph.addEdge( three, new BaseLabeledWeightedEdge<Double>( "3 -> 6", 2D ), six );
+        graph.addEdge( three, new BaseLabeledWeightedEdge<Double>( "3 -> 4", 11D ), four );
 
-        graph.addEdge( four, new BaseLabeledWeightedEdge( "4 -> 5", 6D ), five );
-        graph.addEdge( six, new BaseLabeledWeightedEdge( "6 -> 5", 9D ), five );
+        graph.addEdge( four, new BaseLabeledWeightedEdge<Double>( "4 -> 5", 6D ), five );
+        graph.addEdge( six, new BaseLabeledWeightedEdge<Double>( "6 -> 5", 9D ), five );
 
         // expected path
 
-        InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> expected =
-            new InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge, Double>( one, five, new DoubleWeight() );
+        InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> expected =
+            new InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>( one, five, new DoubleWeight() );
 
-        expected.addConnectionInTail( one, new BaseLabeledWeightedEdge( "1 -> 3", 9D ), three );
-        expected.addConnectionInTail( three, new BaseLabeledWeightedEdge( "3 -> 6", 2D ), six );
-        expected.addConnectionInTail( six, new BaseLabeledWeightedEdge( "6 -> 5", 9D ), five );
+        expected.addConnectionInTail( one, new BaseLabeledWeightedEdge<Double>( "1 -> 3", 9D ), three );
+        expected.addConnectionInTail( three, new BaseLabeledWeightedEdge<Double>( "3 -> 6", 2D ), six );
+        expected.addConnectionInTail( six, new BaseLabeledWeightedEdge<Double>( "6 -> 5", 9D ), five );
 
         // actual path
 
-        Path<BaseLabeledVertex, BaseLabeledWeightedEdge> actual = findShortestPath( graph, one, five );
+        Path<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>> actual = findShortestPath( graph, one, five );
 
         // assert!
 

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=1234551&r1=1234550&r2=1234551&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 Sun Jan 22 17:11:31 2012
@@ -44,20 +44,20 @@ public class FloydWarshallTestCase
     @Test
     public void undirectedShortestPath()
     {
-        findShortestPathAndVerify( new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge>() );
+        findShortestPathAndVerify( new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>() );
     }
 
     @Test
     public void directedShortestPath()
     {
-        findShortestPathAndVerify( new DirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge>() );
+        findShortestPathAndVerify( new DirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>() );
     }
 
-    private void findShortestPathAndVerify( Graph<BaseLabeledVertex, BaseLabeledWeightedEdge> weighted )
+    private void findShortestPathAndVerify( Graph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>> weighted )
     {
         // mutable by definition, generic types driven by input graph
-        MutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge> mutable =
-            (MutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge>) weighted;
+        MutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>> mutable =
+            (MutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>) weighted;
 
         // building Graph
 
@@ -75,20 +75,20 @@ public class FloydWarshallTestCase
         mutable.addVertex( five );
         mutable.addVertex( six );
 
-        mutable.addEdge( one, new BaseLabeledWeightedEdge( "1 -> 6", 14D ), six );
-        mutable.addEdge( one, new BaseLabeledWeightedEdge( "1 -> 3", 9D ), three );
-        mutable.addEdge( one, new BaseLabeledWeightedEdge( "1 -> 2", 7D ), two );
+        mutable.addEdge( one, new BaseLabeledWeightedEdge<Double>( "1 -> 6", 14D ), six );
+        mutable.addEdge( one, new BaseLabeledWeightedEdge<Double>( "1 -> 3", 9D ), three );
+        mutable.addEdge( one, new BaseLabeledWeightedEdge<Double>( "1 -> 2", 7D ), two );
 
-        mutable.addEdge( two, new BaseLabeledWeightedEdge( "2 -> 3", 10D ), three );
-        mutable.addEdge( two, new BaseLabeledWeightedEdge( "2 -> 4", 15D ), four );
+        mutable.addEdge( two, new BaseLabeledWeightedEdge<Double>( "2 -> 3", 10D ), three );
+        mutable.addEdge( two, new BaseLabeledWeightedEdge<Double>( "2 -> 4", 15D ), four );
 
-        mutable.addEdge( three, new BaseLabeledWeightedEdge( "3 -> 6", 2D ), six );
-        mutable.addEdge( three, new BaseLabeledWeightedEdge( "3 -> 4", 11D ), four );
+        mutable.addEdge( three, new BaseLabeledWeightedEdge<Double>( "3 -> 6", 2D ), six );
+        mutable.addEdge( three, new BaseLabeledWeightedEdge<Double>( "3 -> 4", 11D ), four );
 
-        mutable.addEdge( four, new BaseLabeledWeightedEdge( "4 -> 5", 6D ), five );
-        mutable.addEdge( six, new BaseLabeledWeightedEdge( "6 -> 5", 9D ), five );
+        mutable.addEdge( four, new BaseLabeledWeightedEdge<Double>( "4 -> 5", 6D ), five );
+        mutable.addEdge( six, new BaseLabeledWeightedEdge<Double>( "6 -> 5", 9D ), five );
 
-        AllVertexPairsShortestPath<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> p =
+        AllVertexPairsShortestPath<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> p =
             findAllVertexPairsShortestPath( weighted );
 
         if ( weighted instanceof UndirectedGraph )
@@ -106,13 +106,13 @@ public class FloydWarshallTestCase
 
             // Verify shortest paths
 
-            WeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> wp = p.findShortestPath( one, six );
+            WeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> wp = p.findShortestPath( one, six );
 
             // Expected
-            InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> expected =
-                new InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge, Double>( one, six, new DoubleWeight() );
-            expected.addConnectionInTail( one, new BaseLabeledWeightedEdge( "1 -> 3", 9D ), three );
-            expected.addConnectionInTail( three, new BaseLabeledWeightedEdge( "3 -> 6", 2D ), six );
+            InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> expected =
+                new InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>( one, six, new DoubleWeight() );
+            expected.addConnectionInTail( one, new BaseLabeledWeightedEdge<Double>( "1 -> 3", 9D ), three );
+            expected.addConnectionInTail( three, new BaseLabeledWeightedEdge<Double>( "3 -> 6", 2D ), six );
 
             // Actual
             assertEquals( expected, wp );
@@ -126,7 +126,7 @@ public class FloydWarshallTestCase
             assertEquals( 20D, p.getShortestDistance( one, five ) );
             assertFalse( p.hasShortestDistance( five, one ) );
 
-            WeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> wp;
+            WeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> wp;
             // Verify shortest paths
             try
             {
@@ -137,10 +137,10 @@ public class FloydWarshallTestCase
                 // wallow it
             }
 
-            InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> expected =
-                new InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge, Double>( one, six, new DoubleWeight() );
-            expected.addConnectionInTail( one, new BaseLabeledWeightedEdge( "1 -> 3", 9D ), three );
-            expected.addConnectionInTail( three, new BaseLabeledWeightedEdge( "3 -> 6", 2D ), six );
+            InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> expected =
+                new InMemoryWeightedPath<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>( one, six, new DoubleWeight() );
+            expected.addConnectionInTail( one, new BaseLabeledWeightedEdge<Double>( "1 -> 3", 9D ), three );
+            expected.addConnectionInTail( three, new BaseLabeledWeightedEdge<Double>( "3 -> 6", 2D ), six );
 
             // Actual
             wp = p.findShortestPath( one, six );

Modified: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java?rev=1234551&r1=1234550&r2=1234551&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java (original)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java Sun Jan 22 17:11:31 2012
@@ -40,8 +40,8 @@ public final class KruskalTestCase
     @Test
     public void verifyWikipediaMinimumSpanningTree()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge> input
-            = new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge>();
+        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> input
+            = new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>();
 
         BaseLabeledVertex a = new BaseLabeledVertex( "A" );
         BaseLabeledVertex b = new BaseLabeledVertex( "B" );
@@ -59,43 +59,43 @@ public final class KruskalTestCase
         input.addVertex( f );
         input.addVertex( g );
 
-        input.addEdge( a, new BaseLabeledWeightedEdge( "a <-> b", 7D ), b );
-        input.addEdge( a, new BaseLabeledWeightedEdge( "a <-> d", 5D ), d );
+        input.addEdge( a, new BaseLabeledWeightedEdge<Double>( "a <-> b", 7D ), b );
+        input.addEdge( a, new BaseLabeledWeightedEdge<Double>( "a <-> d", 5D ), d );
 
-        input.addEdge( b, new BaseLabeledWeightedEdge( "b <-> c", 8D ), c );
-        input.addEdge( b, new BaseLabeledWeightedEdge( "b <-> d", 9D ), d );
-        input.addEdge( b, new BaseLabeledWeightedEdge( "b <-> e", 7D ), e );
+        input.addEdge( b, new BaseLabeledWeightedEdge<Double>( "b <-> c", 8D ), c );
+        input.addEdge( b, new BaseLabeledWeightedEdge<Double>( "b <-> d", 9D ), d );
+        input.addEdge( b, new BaseLabeledWeightedEdge<Double>( "b <-> e", 7D ), e );
 
-        input.addEdge( c, new BaseLabeledWeightedEdge( "c <-> e", 5D ), e );
+        input.addEdge( c, new BaseLabeledWeightedEdge<Double>( "c <-> e", 5D ), e );
 
-        input.addEdge( d, new BaseLabeledWeightedEdge( "d <-> e", 15D ), e );
-        input.addEdge( d, new BaseLabeledWeightedEdge( "d <-> f", 6D ), f );
+        input.addEdge( d, new BaseLabeledWeightedEdge<Double>( "d <-> e", 15D ), e );
+        input.addEdge( d, new BaseLabeledWeightedEdge<Double>( "d <-> f", 6D ), f );
 
-        input.addEdge( e, new BaseLabeledWeightedEdge( "e <-> f", 8D ), f );
-        input.addEdge( e, new BaseLabeledWeightedEdge( "e <-> g", 9D ), g );
+        input.addEdge( e, new BaseLabeledWeightedEdge<Double>( "e <-> f", 8D ), f );
+        input.addEdge( e, new BaseLabeledWeightedEdge<Double>( "e <-> g", 9D ), g );
 
-        input.addEdge( f, new BaseLabeledWeightedEdge( "f <-> g", 11D ), g );
+        input.addEdge( f, new BaseLabeledWeightedEdge<Double>( "f <-> g", 11D ), g );
 
         // expected
 
-        MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> expected =
-            new MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge, Double>( new DoubleWeight() );
+        MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> expected =
+            new MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>( new DoubleWeight() );
 
         for ( BaseLabeledVertex vertex : input.getVertices() )
         {
             expected.addVertex( vertex );
         }
 
-        expected.addEdge( a, new BaseLabeledWeightedEdge( "a <-> b", 7D ), b );
-        expected.addEdge( a, new BaseLabeledWeightedEdge( "a <-> d", 5D ), d );
-        expected.addEdge( b, new BaseLabeledWeightedEdge( "b <-> e", 9D ), e );
-        expected.addEdge( c, new BaseLabeledWeightedEdge( "c <-> e", 5D ), e );
-        expected.addEdge( d, new BaseLabeledWeightedEdge( "d <-> f", 6D ), f );
-        expected.addEdge( e, new BaseLabeledWeightedEdge( "e <-> g", 9D ), g );
+        expected.addEdge( a, new BaseLabeledWeightedEdge<Double>( "a <-> b", 7D ), b );
+        expected.addEdge( a, new BaseLabeledWeightedEdge<Double>( "a <-> d", 5D ), d );
+        expected.addEdge( b, new BaseLabeledWeightedEdge<Double>( "b <-> e", 9D ), e );
+        expected.addEdge( c, new BaseLabeledWeightedEdge<Double>( "c <-> e", 5D ), e );
+        expected.addEdge( d, new BaseLabeledWeightedEdge<Double>( "d <-> f", 6D ), f );
+        expected.addEdge( e, new BaseLabeledWeightedEdge<Double>( "e <-> g", 9D ), g );
 
         // Actual
 
-        SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> actual = minimumSpanningTree( input );
+        SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> actual = minimumSpanningTree( input );
         
         // assert!
 

Modified: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java?rev=1234551&r1=1234550&r2=1234551&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java (original)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java Sun Jan 22 17:11:31 2012
@@ -40,8 +40,8 @@ public final class PrimTestCase
     @Test
     public void verifyMinimumSpanningTree2()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge> input
-            = new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge>();
+        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> input
+            = new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>();
 
         BaseLabeledVertex a = new BaseLabeledVertex( "a" );
         BaseLabeledVertex b = new BaseLabeledVertex( "b" );
@@ -59,39 +59,39 @@ public final class PrimTestCase
         input.addVertex( f );
         input.addVertex( g );
 
-        input.addEdge( a, new BaseLabeledWeightedEdge( "a <-> b", 7D ), b );
-        input.addEdge( a, new BaseLabeledWeightedEdge( "a <-> c", 14D ), c );
-        input.addEdge( a, new BaseLabeledWeightedEdge( "a <-> d", 30D ), d );
+        input.addEdge( a, new BaseLabeledWeightedEdge<Double>( "a <-> b", 7D ), b );
+        input.addEdge( a, new BaseLabeledWeightedEdge<Double>( "a <-> c", 14D ), c );
+        input.addEdge( a, new BaseLabeledWeightedEdge<Double>( "a <-> d", 30D ), d );
 
-        input.addEdge( b, new BaseLabeledWeightedEdge( "b <-> c", 21D ), c );
+        input.addEdge( b, new BaseLabeledWeightedEdge<Double>( "b <-> c", 21D ), c );
 
-        input.addEdge( c, new BaseLabeledWeightedEdge( "c <-> d", 10D ), d );
-        input.addEdge( c, new BaseLabeledWeightedEdge( "c <-> e", 1D ), e );
+        input.addEdge( c, new BaseLabeledWeightedEdge<Double>( "c <-> d", 10D ), d );
+        input.addEdge( c, new BaseLabeledWeightedEdge<Double>( "c <-> e", 1D ), e );
 
-        input.addEdge( e, new BaseLabeledWeightedEdge( "e <-> f", 6D ), f );
-        input.addEdge( e, new BaseLabeledWeightedEdge( "e <-> g", 9D ), g );
+        input.addEdge( e, new BaseLabeledWeightedEdge<Double>( "e <-> f", 6D ), f );
+        input.addEdge( e, new BaseLabeledWeightedEdge<Double>( "e <-> g", 9D ), g );
 
-        input.addEdge( f, new BaseLabeledWeightedEdge( "f <-> g", 4D ), g );
+        input.addEdge( f, new BaseLabeledWeightedEdge<Double>( "f <-> g", 4D ), g );
 
         // expected
 
-        MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> expected =
-            new MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge, Double>( new DoubleWeight() );
+        MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> expected =
+            new MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>( new DoubleWeight() );
 
         for ( BaseLabeledVertex vertex : input.getVertices() )
         {
             expected.addVertex( vertex );
         }
 
-        expected.addEdge( a, new BaseLabeledWeightedEdge( "a <-> b", 7D ), b );
-        expected.addEdge( a, new BaseLabeledWeightedEdge( "a <-> c", 14D ), c );
+        expected.addEdge( a, new BaseLabeledWeightedEdge<Double>( "a <-> b", 7D ), b );
+        expected.addEdge( a, new BaseLabeledWeightedEdge<Double>( "a <-> c", 14D ), c );
 
-        expected.addEdge( c, new BaseLabeledWeightedEdge( "c <-> d", 10D ), d );
-        expected.addEdge( c, new BaseLabeledWeightedEdge( "c <-> e", 1D ), e );
+        expected.addEdge( c, new BaseLabeledWeightedEdge<Double>( "c <-> d", 10D ), d );
+        expected.addEdge( c, new BaseLabeledWeightedEdge<Double>( "c <-> e", 1D ), e );
 
-        expected.addEdge( e, new BaseLabeledWeightedEdge( "e <-> f", 6D ), f );
+        expected.addEdge( e, new BaseLabeledWeightedEdge<Double>( "e <-> f", 6D ), f );
 
-        expected.addEdge( f, new BaseLabeledWeightedEdge( "f <-> g", 4D ), g );
+        expected.addEdge( f, new BaseLabeledWeightedEdge<Double>( "f <-> g", 4D ), g );
 
         internalPrimAssertion( input, a, expected );
     }
@@ -103,8 +103,8 @@ public final class PrimTestCase
     @Test
     public void verifyWikipediaMinimumSpanningTree()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge> input
-            = new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge>();
+        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> input
+            = new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>();
 
         BaseLabeledVertex a = new BaseLabeledVertex( "A" );
         BaseLabeledVertex b = new BaseLabeledVertex( "B" );
@@ -122,50 +122,50 @@ public final class PrimTestCase
         input.addVertex( f );
         input.addVertex( g );
 
-        input.addEdge( a, new BaseLabeledWeightedEdge( "a <-> b", 7D ), b );
-        input.addEdge( a, new BaseLabeledWeightedEdge( "a <-> d", 5D ), d );
+        input.addEdge( a, new BaseLabeledWeightedEdge<Double>( "a <-> b", 7D ), b );
+        input.addEdge( a, new BaseLabeledWeightedEdge<Double>( "a <-> d", 5D ), d );
 
-        input.addEdge( b, new BaseLabeledWeightedEdge( "b <-> c", 8D ), c );
-        input.addEdge( b, new BaseLabeledWeightedEdge( "b <-> d", 9D ), d );
-        input.addEdge( b, new BaseLabeledWeightedEdge( "b <-> e", 7D ), e );
+        input.addEdge( b, new BaseLabeledWeightedEdge<Double>( "b <-> c", 8D ), c );
+        input.addEdge( b, new BaseLabeledWeightedEdge<Double>( "b <-> d", 9D ), d );
+        input.addEdge( b, new BaseLabeledWeightedEdge<Double>( "b <-> e", 7D ), e );
 
-        input.addEdge( c, new BaseLabeledWeightedEdge( "c <-> e", 5D ), e );
+        input.addEdge( c, new BaseLabeledWeightedEdge<Double>( "c <-> e", 5D ), e );
 
-        input.addEdge( d, new BaseLabeledWeightedEdge( "d <-> e", 15D ), e );
-        input.addEdge( d, new BaseLabeledWeightedEdge( "d <-> f", 6D ), f );
+        input.addEdge( d, new BaseLabeledWeightedEdge<Double>( "d <-> e", 15D ), e );
+        input.addEdge( d, new BaseLabeledWeightedEdge<Double>( "d <-> f", 6D ), f );
 
-        input.addEdge( e, new BaseLabeledWeightedEdge( "e <-> f", 8D ), f );
-        input.addEdge( e, new BaseLabeledWeightedEdge( "e <-> g", 9D ), g );
+        input.addEdge( e, new BaseLabeledWeightedEdge<Double>( "e <-> f", 8D ), f );
+        input.addEdge( e, new BaseLabeledWeightedEdge<Double>( "e <-> g", 9D ), g );
 
-        input.addEdge( f, new BaseLabeledWeightedEdge( "f <-> g", 11D ), g );
+        input.addEdge( f, new BaseLabeledWeightedEdge<Double>( "f <-> g", 11D ), g );
 
         // expected
 
-        MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> expected =
-            new MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge, Double>( new DoubleWeight() );
+        MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> expected =
+            new MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>( new DoubleWeight() );
 
         for ( BaseLabeledVertex vertex : input.getVertices() )
         {
             expected.addVertex( vertex );
         }
 
-        expected.addEdge( a, new BaseLabeledWeightedEdge( "a <-> b", 7D ), b );
-        expected.addEdge( a, new BaseLabeledWeightedEdge( "a <-> d", 5D ), d );
-        expected.addEdge( b, new BaseLabeledWeightedEdge( "b <-> e", 9D ), e );
-        expected.addEdge( c, new BaseLabeledWeightedEdge( "c <-> e", 5D ), e );
-        expected.addEdge( d, new BaseLabeledWeightedEdge( "d <-> f", 6D ), f );
-        expected.addEdge( e, new BaseLabeledWeightedEdge( "e <-> g", 9D ), g );
+        expected.addEdge( a, new BaseLabeledWeightedEdge<Double>( "a <-> b", 7D ), b );
+        expected.addEdge( a, new BaseLabeledWeightedEdge<Double>( "a <-> d", 5D ), d );
+        expected.addEdge( b, new BaseLabeledWeightedEdge<Double>( "b <-> e", 9D ), e );
+        expected.addEdge( c, new BaseLabeledWeightedEdge<Double>( "c <-> e", 5D ), e );
+        expected.addEdge( d, new BaseLabeledWeightedEdge<Double>( "d <-> f", 6D ), f );
+        expected.addEdge( e, new BaseLabeledWeightedEdge<Double>( "e <-> g", 9D ), g );
 
         internalPrimAssertion( input, d, expected );
     }
 
-    private static void internalPrimAssertion( UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge> input,
+    private static void internalPrimAssertion( UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> input,
                                                BaseLabeledVertex source,
-                                               MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> expected )
+                                               MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> expected )
     {
      // actual
 
-        SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge, Double> actual = minimumSpanningTree( input, source );
+        SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> actual = minimumSpanningTree( input, source );
 
         // assert!
 



Mime
View raw message