commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1298188 - in /commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning: BoruvkaTestCase.java KruskalTestCase.java PrimTestCase.java ReverseDeleteTestCase.java
Date Wed, 07 Mar 2012 22:56:04 GMT
Author: simonetripodi
Date: Wed Mar  7 22:56:04 2012
New Revision: 1298188

URL: http://svn.apache.org/viewvc?rev=1298188&view=rev
Log:
SpanningTree algos refactored according to new APIs

Modified:
    commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java
    commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java
    commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java
    commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/ReverseDeleteTestCase.java

Modified: commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java?rev=1298188&r1=1298187&r2=1298188&view=diff
==============================================================================
--- commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java
(original)
+++ commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java
Wed Mar  7 22:56:04 2012
@@ -23,9 +23,13 @@ import static junit.framework.Assert.ass
 import static junit.framework.Assert.fail;
 import static org.apache.commons.graph.CommonsGraph.minimumSpanningTree;
 
+import org.apache.commons.graph.Graph;
+import org.apache.commons.graph.SpanningTree;
 import org.apache.commons.graph.model.BaseLabeledVertex;
 import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.model.BaseWeightedEdge;
 import org.apache.commons.graph.model.MutableSpanningTree;
+import org.apache.commons.graph.model.UndirectedMutableGraph;
 import org.apache.commons.graph.weight.primitive.DoubleWeightBaseOperations;
 import org.junit.Test;
 
@@ -35,25 +39,31 @@ public final class BoruvkaTestCase
     @Test( expected = NullPointerException.class )
     public void testNullGraph()
     {
-        minimumSpanningTree( (WeightedGraph<Vertex, WeightedEdge<Double>, Double>)
null ).fromArbitrarySource().applyingBoruvkaAlgorithm( new DoubleWeightBaseOperations() );
+        minimumSpanningTree( (Graph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>)
null )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromArbitrarySource()
+            .applyingBoruvkaAlgorithm( new DoubleWeightBaseOperations() );
     }
 
     @Test( expected = NullPointerException.class )
     public void testNullVertex()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
-        minimumSpanningTree( input ).fromSource( null ).applyingBoruvkaAlgorithm( new DoubleWeightBaseOperations()
);
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
+        minimumSpanningTree( input )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromSource( null )
+            .applyingBoruvkaAlgorithm( new DoubleWeightBaseOperations() );
     }
 
     @Test( expected = NullPointerException.class )
     public void testNullMonoid()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input = null;
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input = null;
         BaseLabeledVertex a = null;
         try
         {
-            input = new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+            input = new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
             a = new BaseLabeledVertex( "A" );
             input.addVertex( a );
         }
@@ -63,25 +73,33 @@ public final class BoruvkaTestCase
             fail( e.getMessage() );
         }
 
-        minimumSpanningTree( input ).fromSource( a ).applyingBoruvkaAlgorithm( null );
+        minimumSpanningTree( input )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromSource( a )
+            .applyingBoruvkaAlgorithm( null );
     }
-    
+
     @Test( expected = IllegalStateException.class )
     public void testNotExistVertex()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
-        minimumSpanningTree( input ).fromSource( new BaseLabeledVertex( "NOT EXIST" ) );
+        minimumSpanningTree( input )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromSource( new BaseLabeledVertex( "NOT EXIST" ) );
     }
-    
+
     @Test( expected = IllegalStateException.class )
     public void testEmptyGraph()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
-        minimumSpanningTree( input ).fromArbitrarySource().applyingBoruvkaAlgorithm( new
DoubleWeightBaseOperations() );
+        minimumSpanningTree( input )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromArbitrarySource()
+            .applyingBoruvkaAlgorithm( new DoubleWeightBaseOperations() );
     }
 
     /**
@@ -90,8 +108,8 @@ public final class BoruvkaTestCase
     @Test
     public void verifyWikipediaMinimumSpanningTree()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
         BaseLabeledVertex a = new BaseLabeledVertex( "A" );
         BaseLabeledVertex b = new BaseLabeledVertex( "B" );
@@ -143,7 +161,10 @@ public final class BoruvkaTestCase
         // Actual
 
         SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>
actual =
-            minimumSpanningTree( input ).fromArbitrarySource().applyingBoruvkaAlgorithm(
new DoubleWeightBaseOperations() );
+            minimumSpanningTree( input )
+                .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+                .fromArbitrarySource()
+                .applyingBoruvkaAlgorithm( new DoubleWeightBaseOperations() );
 
         // assert!
 
@@ -156,8 +177,8 @@ public final class BoruvkaTestCase
     @Test( expected = IllegalStateException.class )
     public void verifySparseGraphMinimumSpanningTree()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
         input.addVertex( new BaseLabeledVertex( "A" ) );
         input.addVertex( new BaseLabeledVertex( "B" ) );
@@ -167,7 +188,10 @@ public final class BoruvkaTestCase
         input.addVertex( new BaseLabeledVertex( "F" ) );
         input.addVertex( new BaseLabeledVertex( "G" ) );
 
-        minimumSpanningTree( input ).fromArbitrarySource().applyingBoruvkaAlgorithm( new
DoubleWeightBaseOperations() );
+        minimumSpanningTree( input )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromArbitrarySource()
+            .applyingBoruvkaAlgorithm( new DoubleWeightBaseOperations() );
     }
 
 }

Modified: commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java?rev=1298188&r1=1298187&r2=1298188&view=diff
==============================================================================
--- commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java
(original)
+++ commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java
Wed Mar  7 22:56:04 2012
@@ -23,9 +23,13 @@ import static junit.framework.Assert.ass
 import static junit.framework.Assert.fail;
 import static org.apache.commons.graph.CommonsGraph.minimumSpanningTree;
 
+import org.apache.commons.graph.Graph;
+import org.apache.commons.graph.SpanningTree;
 import org.apache.commons.graph.model.BaseLabeledVertex;
 import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.model.BaseWeightedEdge;
 import org.apache.commons.graph.model.MutableSpanningTree;
+import org.apache.commons.graph.model.UndirectedMutableGraph;
 import org.apache.commons.graph.weight.primitive.DoubleWeightBaseOperations;
 import org.junit.Test;
 
@@ -35,25 +39,31 @@ public final class KruskalTestCase
     @Test( expected = NullPointerException.class )
     public void testNullGraph()
     {
-        minimumSpanningTree( (WeightedGraph<Vertex, WeightedEdge<Double>, Double>)
null ).fromArbitrarySource().applyingKruskalAlgorithm( new DoubleWeightBaseOperations() );
+        minimumSpanningTree( (Graph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>)
null )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromArbitrarySource()
+            .applyingKruskalAlgorithm( new DoubleWeightBaseOperations() );
     }
 
     @Test( expected = NullPointerException.class )
     public void testNullVertex()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
-        minimumSpanningTree( input ).fromSource( null ).applyingKruskalAlgorithm( new DoubleWeightBaseOperations()
);
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
+        minimumSpanningTree( input )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromSource( null )
+            .applyingKruskalAlgorithm( new DoubleWeightBaseOperations() );
     }
 
     @Test( expected = NullPointerException.class )
     public void testNullMonoid()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input = null;
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input = null;
         BaseLabeledVertex a = null;
         try
         {
-            input = new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+            input = new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
             a = new BaseLabeledVertex( "A" );
             input.addVertex( a );
         }
@@ -63,27 +73,35 @@ public final class KruskalTestCase
             fail( e.getMessage() );
         }
 
-        minimumSpanningTree( input ).fromSource( a ).applyingKruskalAlgorithm( null );
+        minimumSpanningTree( input )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromSource( a )
+            .applyingKruskalAlgorithm( null );
     }
-    
+
     @Test( expected = IllegalStateException.class )
     public void testNotExistVertex()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
-        minimumSpanningTree( input ).fromSource( new BaseLabeledVertex( "NOT EXIST" ) );
+        minimumSpanningTree( input )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromSource( new BaseLabeledVertex( "NOT EXIST" ) );
     }
-    
+
     @Test( expected = IllegalStateException.class )
     public void testEmptyGraph()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
-        minimumSpanningTree( input ).fromArbitrarySource().applyingKruskalAlgorithm( new
DoubleWeightBaseOperations() );
+        minimumSpanningTree( input )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromArbitrarySource()
+            .applyingKruskalAlgorithm( new DoubleWeightBaseOperations() );
     }
-    
+
     /**
      * Test Graph and Prim's solution can be seen on
      * <a href="http://en.wikipedia.org/wiki/Prim%27s_algorithm">Wikipedia</a>
@@ -91,8 +109,8 @@ public final class KruskalTestCase
     @Test
     public void verifyWikipediaMinimumSpanningTree()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input
-            = new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input
+            = new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
         BaseLabeledVertex a = new BaseLabeledVertex( "A" );
         BaseLabeledVertex b = new BaseLabeledVertex( "B" );
@@ -148,7 +166,11 @@ public final class KruskalTestCase
 
         // Actual
 
-        SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>
actual = minimumSpanningTree( input ).fromArbitrarySource().applyingKruskalAlgorithm( new
DoubleWeightBaseOperations() );
+        SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>
actual =
+                        minimumSpanningTree( input )
+                            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>()
)
+                            .fromArbitrarySource()
+                            .applyingKruskalAlgorithm( new DoubleWeightBaseOperations() );
 
         // assert!
 
@@ -163,8 +185,8 @@ public final class KruskalTestCase
     @Test
     public void verifyNotConnectedMinimumSpanningTree()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input
-            = new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input
+            = new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
         BaseLabeledVertex a = new BaseLabeledVertex( "A" );
         BaseLabeledVertex b = new BaseLabeledVertex( "B" );
@@ -193,7 +215,11 @@ public final class KruskalTestCase
 
         // Actual
 
-        SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>
actual = minimumSpanningTree( input ).fromArbitrarySource().applyingKruskalAlgorithm( new
DoubleWeightBaseOperations() );
+        SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>
actual =
+                        minimumSpanningTree( input )
+                            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>()
)
+                            .fromArbitrarySource()
+                            .applyingKruskalAlgorithm( new DoubleWeightBaseOperations() );
 
         // assert!
 

Modified: commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java?rev=1298188&r1=1298187&r2=1298188&view=diff
==============================================================================
--- commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java
(original)
+++ commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java
Wed Mar  7 22:56:04 2012
@@ -23,9 +23,13 @@ import static junit.framework.Assert.ass
 import static junit.framework.Assert.fail;
 import static org.apache.commons.graph.CommonsGraph.minimumSpanningTree;
 
+import org.apache.commons.graph.Graph;
+import org.apache.commons.graph.SpanningTree;
 import org.apache.commons.graph.model.BaseLabeledVertex;
 import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.model.BaseWeightedEdge;
 import org.apache.commons.graph.model.MutableSpanningTree;
+import org.apache.commons.graph.model.UndirectedMutableGraph;
 import org.apache.commons.graph.weight.primitive.DoubleWeightBaseOperations;
 import org.junit.Test;
 
@@ -34,26 +38,32 @@ public final class PrimTestCase
     @Test( expected = NullPointerException.class )
     public void testNullGraph()
     {
-        minimumSpanningTree( (WeightedGraph<Vertex, WeightedEdge<Double>, Double>)
null ).fromArbitrarySource().applyingPrimAlgorithm( new DoubleWeightBaseOperations() );
+        minimumSpanningTree( (Graph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>)
null )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromArbitrarySource()
+            .applyingPrimAlgorithm( new DoubleWeightBaseOperations() );
     }
 
     @Test( expected = NullPointerException.class )
     public void testNullVertex()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
-        minimumSpanningTree( input ).fromSource( null ).applyingPrimAlgorithm( new DoubleWeightBaseOperations()
);
+        minimumSpanningTree( input )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromSource( null )
+            .applyingPrimAlgorithm( new DoubleWeightBaseOperations() );
     }
 
     @Test( expected = NullPointerException.class )
     public void testNullMonoid()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input = null;
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input = null;
         BaseLabeledVertex a = null;
         try
         {
-            input = new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+            input = new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
             a = new BaseLabeledVertex( "A" );
             input.addVertex( a );
         }
@@ -63,25 +73,33 @@ public final class PrimTestCase
             fail( e.getMessage() );
         }
 
-        minimumSpanningTree( input ).fromSource( a ).applyingBoruvkaAlgorithm( null );
+        minimumSpanningTree( input )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromSource( a )
+            .applyingBoruvkaAlgorithm( null );
     }
-    
+
     @Test( expected = IllegalStateException.class )
     public void testNotExistVertex()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
-        minimumSpanningTree( input ).fromSource( new BaseLabeledVertex( "NOT EXIST" ) );
+        minimumSpanningTree( input )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromSource( new BaseLabeledVertex( "NOT EXIST" ) );
     }
-    
+
     @Test( expected = IllegalStateException.class )
     public void testEmptyGraph()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
-        minimumSpanningTree( input ).fromArbitrarySource().applyingPrimAlgorithm( new DoubleWeightBaseOperations()
);
+        minimumSpanningTree( input )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .fromArbitrarySource()
+            .applyingPrimAlgorithm( new DoubleWeightBaseOperations() );
     }
 
     /**
@@ -91,8 +109,8 @@ public final class PrimTestCase
     @Test
     public void verifyMinimumSpanningTree2()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input
-            = new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input
+            = new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
         BaseLabeledVertex a = new BaseLabeledVertex( "a" );
         BaseLabeledVertex b = new BaseLabeledVertex( "b" );
@@ -154,8 +172,8 @@ public final class PrimTestCase
     @Test
     public void verifyWikipediaMinimumSpanningTree()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input
-            = new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input
+            = new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
         BaseLabeledVertex a = new BaseLabeledVertex( "A" );
         BaseLabeledVertex b = new BaseLabeledVertex( "B" );
@@ -210,13 +228,17 @@ public final class PrimTestCase
         internalPrimAssertion( input, d, expected );
     }
 
-    private static void internalPrimAssertion( UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> input,
+    private static void internalPrimAssertion( UndirectedMutableGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>> input,
                                                BaseLabeledVertex source,
                                                MutableSpanningTree<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> expected )
     {
      // actual
 
-        SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>
actual = minimumSpanningTree( input ).fromSource( source ).applyingPrimAlgorithm( new DoubleWeightBaseOperations()
);
+        SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>
actual =
+                        minimumSpanningTree( input )
+                            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>()
)
+                            .fromSource( source )
+                            .applyingPrimAlgorithm( new DoubleWeightBaseOperations() );
 
         // assert!
 

Modified: commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/ReverseDeleteTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/ReverseDeleteTestCase.java?rev=1298188&r1=1298187&r2=1298188&view=diff
==============================================================================
--- commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/ReverseDeleteTestCase.java
(original)
+++ commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/test/java/org/apache/commons/graph/spanning/ReverseDeleteTestCase.java
Wed Mar  7 22:56:04 2012
@@ -22,9 +22,13 @@ package org.apache.commons.graph.spannin
 import static junit.framework.Assert.assertEquals;
 import static org.apache.commons.graph.CommonsGraph.minimumSpanningTree;
 
+import org.apache.commons.graph.Graph;
+import org.apache.commons.graph.SpanningTree;
 import org.apache.commons.graph.model.BaseLabeledVertex;
 import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.model.BaseWeightedEdge;
 import org.apache.commons.graph.model.MutableSpanningTree;
+import org.apache.commons.graph.model.UndirectedMutableGraph;
 import org.apache.commons.graph.weight.primitive.DoubleWeightBaseOperations;
 import org.junit.Test;
 
@@ -37,39 +41,45 @@ public class ReverseDeleteTestCase
     @Test( expected = NullPointerException.class )
     public void testNullGraph()
     {
-        minimumSpanningTree( (WeightedGraph<Vertex, WeightedEdge<Double>, Double>)
null ).applyingReverseDeleteAlgorithm( new DoubleWeightBaseOperations() );
+        minimumSpanningTree( (Graph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>)
null )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .applyingReverseDeleteAlgorithm( new DoubleWeightBaseOperations() );
     }
 
     @Test( expected = NullPointerException.class )
     public void testNullMonoid()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input = null;
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input = null;
 
-        minimumSpanningTree( input ).applyingReverseDeleteAlgorithm( null );
+        minimumSpanningTree( input )
+            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+            .applyingReverseDeleteAlgorithm( null );
     }
-    
+
     @Test
     public void testEmptyGraph()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
         SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>
tree =
-            minimumSpanningTree( input ).applyingReverseDeleteAlgorithm( new DoubleWeightBaseOperations()
);
+            minimumSpanningTree( input )
+                .whereEdgesHaveWeights( new BaseWeightedEdge<Double>() )
+                .applyingReverseDeleteAlgorithm( new DoubleWeightBaseOperations() );
 
         assertEquals( 0, tree.getOrder() );
         assertEquals( 0, tree.getSize() );
 
     }
-    
+
     /**
      * Test Graph and Reverse-Delete Algorithm
      */
     @Test
     public void verifyMinimumSpanningTree()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
         BaseLabeledVertex a = new BaseLabeledVertex( "a" );
         BaseLabeledVertex b = new BaseLabeledVertex( "b" );
@@ -97,7 +107,9 @@ public class ReverseDeleteTestCase
         expected.addEdge( c, new BaseLabeledWeightedEdge<Double>( "c <-> a",
4D ), a );
 
         SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>
actual =
-                        minimumSpanningTree( input ).applyingReverseDeleteAlgorithm( new
DoubleWeightBaseOperations() );
+                        minimumSpanningTree( input )
+                            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>()
)
+                            .applyingReverseDeleteAlgorithm( new DoubleWeightBaseOperations()
);
         assertEquals( expected, actual );
     }
 
@@ -107,8 +119,8 @@ public class ReverseDeleteTestCase
     @Test
     public void verifyNotConnectGraph()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
         BaseLabeledVertex a = new BaseLabeledVertex( "a" );
         BaseLabeledVertex b = new BaseLabeledVertex( "b" );
@@ -129,7 +141,9 @@ public class ReverseDeleteTestCase
         }
 
         SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>
actual =
-                        minimumSpanningTree( input ).applyingReverseDeleteAlgorithm( new
DoubleWeightBaseOperations() );
+                        minimumSpanningTree( input )
+                            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>()
)
+                            .applyingReverseDeleteAlgorithm( new DoubleWeightBaseOperations()
);
         assertEquals( expected, actual );
     }
 
@@ -139,8 +153,8 @@ public class ReverseDeleteTestCase
     @Test
     public void verifyNotConnectGraph2()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
         BaseLabeledVertex a = new BaseLabeledVertex( "a" );
         BaseLabeledVertex b = new BaseLabeledVertex( "b" );
@@ -177,7 +191,9 @@ public class ReverseDeleteTestCase
         expected.addEdge( d, new BaseLabeledWeightedEdge<Double>( "d <-> e",
4D ), e );
 
         SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>
actual =
-                        minimumSpanningTree( input ).applyingReverseDeleteAlgorithm( new
DoubleWeightBaseOperations() );
+                        minimumSpanningTree( input )
+                            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>()
)
+                            .applyingReverseDeleteAlgorithm( new DoubleWeightBaseOperations()
);
         assertEquals( expected, actual );
     }
 
@@ -188,8 +204,8 @@ public class ReverseDeleteTestCase
     @Test
     public void verifyNotConnectGraph3()
     {
-        UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double> input =
-            new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>,
Double>();
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>
input =
+            new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>();
 
         BaseLabeledVertex a = new BaseLabeledVertex( "a" );
         BaseLabeledVertex b = new BaseLabeledVertex( "b" );
@@ -231,7 +247,9 @@ public class ReverseDeleteTestCase
         expected.addEdge( f, new BaseLabeledWeightedEdge<Double>( "f <-> d",
4D ), d );
 
         SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>
actual =
-                        minimumSpanningTree( input ).applyingReverseDeleteAlgorithm( new
DoubleWeightBaseOperations() );
+                        minimumSpanningTree( input )
+                            .whereEdgesHaveWeights( new BaseWeightedEdge<Double>()
)
+                            .applyingReverseDeleteAlgorithm( new DoubleWeightBaseOperations()
);
         assertEquals( expected, actual );
     }
 



Mime
View raw message