You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2005/02/26 14:24:10 UTC

svn commit: r155447 [4/4] - in jakarta/commons/sandbox/graph2/trunk: ./ src/java/org/apache/commons/graph/ src/java/org/apache/commons/graph/algorithm/dataflow/ src/java/org/apache/commons/graph/algorithm/path/ src/java/org/apache/commons/graph/algorithm/search/ src/java/org/apache/commons/graph/algorithm/spanning/ src/java/org/apache/commons/graph/algorithm/util/ src/java/org/apache/commons/graph/contract/ src/java/org/apache/commons/graph/decorator/ src/java/org/apache/commons/graph/domain/basic/ src/java/org/apache/commons/graph/domain/dependency/ src/java/org/apache/commons/graph/domain/dependency/exception/ src/java/org/apache/commons/graph/domain/jdepend/ src/java/org/apache/commons/graph/domain/statemachine/ src/java/org/apache/commons/graph/domain/statemachine/exception/ src/java/org/apache/commons/graph/exception/ src/java/org/apache/commons/graph/factory/ src/java/org/apache/commons/graph/search/ src/java/org/apache/commons/graph/visualize/ src/test/org/apache/commons/graph/ src/test/org/apache/commons/graph/algorithm/dataflow/ src/test/org/apache/commons/graph/algorithm/path/ src/test/org/apache/commons/graph/algorithm/spanning/ src/test/org/apache/commons/graph/algorithm/util/ src/test/org/apache/commons/graph/contract/ src/test/org/apache/commons/graph/decorator/ src/test/org/apache/commons/graph/domain/dependency/ xdocs/

Modified: jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/algorithm/spanning/MinimumSpanningForestTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/algorithm/spanning/MinimumSpanningForestTest.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/algorithm/spanning/MinimumSpanningForestTest.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/algorithm/spanning/MinimumSpanningForestTest.java Sat Feb 26 05:21:52 2005
@@ -1,367 +1,367 @@
-package org.apache.commons.graph.algorithm.spanning;
-
-import java.util.Set;
-
-import org.apache.commons.graph.*;
-import org.apache.commons.graph.exception.*;
-
-public class MinimumSpanningForestTest
-  extends WeightedGraphTest
-{
-  private String name = null;
-
-  public MinimumSpanningForestTest( String name ) {
-    super( name );
-    this.name = name;
-  }
-
-  public void testNullGraph() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeNullGraph();
-    MinimumSpanningForest msf = 
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 0, 0 );
-    verifyChords( msf, makeSet() );
-  }
-  
-  public void testDirNullGraph() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeDirNullGraph();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 0, 0 );
-    verifyChords( msf, makeSet() );
-  }
-
-  public void testSingleVertex() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeSingleVertex();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 1, 0 );
-    verifyChords( msf, makeSet() );
-  }
-
-  public void testDirSingleVertex() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeDirSingleVertex();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 1, 0 );
-    verifyChords( msf, makeSet() );
-  }
-
-  public void testSelfLoop() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeSelfLoop();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 1, 0 );
-
-    verifyChords(msf, makeSet( V1_V1 ));
-  }
-
-  public void testDoubleVertex() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeDoubleVertex();
-    MinimumSpanningForest msf = 
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 2, 0 );
-    verifyChords(msf, makeSet() );
-  }
-
-  public void testDirDoubleVertex() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeDirDoubleVertex();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 2, 0 );
-    verifyChords( msf, makeSet() );
-  }
-
-  public void testSingleEdge() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeSingleEdge();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 2, 1 );
-    verifyChords( msf, makeSet());
-  }
-
-  public void testDirectedEdge() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeDirectedEdge();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 2, 1 );
-    verifyChords( msf, makeSet());
-  }
-
-  public void testParallelEdges() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeParallelEdges();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 2, 1 );
-  }
-
-  public void testDirParallelEdges() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeDirParallelEdges();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 2, 1 );
-  }
-
-  public void testCycle() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeCycle();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 3, 2 );
-  }
-
-  public void testTwoCycle() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeTwoCycle();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 2, 1 );
-  }
-
-  public void testDirectedCycle() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeDirectedCycle();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 3, 2 );
-  }
-
-  public void testNoCycle() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeNoCycle();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 3, 2 );
-  }
-
-  public void testPipe() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makePipe();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 3, 2 );
-  }
-
-  public void testDiamond() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeDiamond();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 4, 3 );
-  }
-
-  public void testPipelessCycle() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makePipelessCycle();
-    MinimumSpanningForest msf =
-      new MinimumSpanningForest( graph );
-    verifyGraph( msf, 4, 3 );
-  }
-
-  public void testHyperGraph() throws Throwable {
-    WeightedGraph graph = (WeightedGraph) makeHyperGraph();
-    try {
-      MinimumSpanningForest msf =
-	new MinimumSpanningForest( graph );
-      fail("HyperGraph Exception not thrown.");
-    } catch (HyperGraphException hge) { }
-  }
-
-  public void testWDirectedEdge()
-    throws Throwable
-  {
-    WeightedGraph graph = makeWDirectedEdge();
-    
-    MinimumSpanningForest msf = 
-      new MinimumSpanningForest( graph );
-    
-    verifyGraph( msf, 2, 1 );
-    verifyEdges( msf, makeSet( V1_V2 ) );
-    assertEquals("Edge Weight not the same.",
-		 5.0, msf.getWeight(V1_V2), 0.00001 );
-    verifyChords( msf, makeSet() );
-  }
-
-  public void testWSelfLoop()
-    throws Throwable
-  {
-    MinimumSpanningForest IUT = 
-      new MinimumSpanningForest( makeWSelfLoop() );
-    verifyGraph(IUT, 1, 0);
-    verifyEdges(IUT, makeSet() );
-    verifyChords(IUT, makeSet( V1_V1 ));
-  }
-
-  public void testPositiveCycle() 
-    throws Throwable
-  {
-    MinimumSpanningForest IUT =
-      new MinimumSpanningForest( makePositiveCycle() );
-    verifyGraph( IUT, 3, 2 );
-    verifyEdges( IUT, makeSet( V3_V1, V1_V2 ));
-    verifyChords( IUT, makeSet( V2_V3 ));
-  }
-
-  public void testPositivePartNegCycle()
-    throws Throwable
-  {
-    MinimumSpanningForest IUT =
-      new MinimumSpanningForest( makePositivePartNegCycle() );
-    verifyGraph( IUT, 3, 2 );
-    verifyEdges( IUT, makeSet( V3_V1, V1_V2 ) );
-    verifyChords( IUT, makeSet( V2_V3 ));
-  }
-
-  public void testNegativeCycle()
-    throws Throwable
-  {
-    MinimumSpanningForest IUT =
-      new MinimumSpanningForest( makeNegativeCycle() );
-    
-    verifyGraph( IUT, 3, 2 );
-    verifyEdges( IUT, makeSet( V2_V3, V1_V2 ));
-    verifyChords( IUT, makeSet( V3_V1 ));
-  }
-
-  public void testNegativePartPosCycle()
-    throws Throwable
-  {
-    MinimumSpanningForest IUT =
-      new MinimumSpanningForest( makeNegativePartPosCycle() );
-    
-    verifyGraph( IUT, 3, 2 );
-    verifyEdges( IUT, makeSet( V2_V3, V1_V2 ));
-    verifyChords( IUT, makeSet( V3_V1 ));
-  }
-
-  public void testPositivePipe()
-    throws Throwable
-  {
-    MinimumSpanningForest IUT =
-      new MinimumSpanningForest( makePositivePipe() );
-    
-    verifyGraph( IUT, 3, 2 );
-    verifyEdges( IUT, makeSet( V1_V2, V2_V3 ));
-    verifyChords(IUT, makeSet());
-  }
-
-  public void testPositivePartNegPipe()
-    throws Throwable
-  {
-    MinimumSpanningForest IUT =
-      new MinimumSpanningForest( makePositivePartNegPipe() );
-    
-    verifyGraph( IUT, 3, 2 );
-    verifyEdges( IUT, makeSet( V1_V2, V2_V3 ));
-    verifyChords(IUT,  makeSet());
-  }
-
-  public void testNegativePipe()
-    throws Throwable
-  {
-    MinimumSpanningForest IUT =
-      new MinimumSpanningForest( makeNegativePipe() );
-    
-    verifyGraph( IUT, 3, 2 );
-    verifyEdges( IUT, makeSet( V1_V2, V2_V3 ));
-    verifyChords(IUT, makeSet());
-  }
-
-  public void testNegativePartPosPipe()
-    throws Throwable
-  {
-    MinimumSpanningForest IUT =
-      new MinimumSpanningForest( makeNegativePartPosPipe() );
-    
-    verifyGraph( IUT, 3, 2 );
-    verifyEdges( IUT, makeSet( V1_V2, V2_V3 ));
-    verifyChords(IUT, makeSet());
-  }
-
-  public void testMultiplePathL()
-    throws Throwable
-  {
-    MinimumSpanningForest IUT =
-      new MinimumSpanningForest( makeMultiplePathL() );
-    
-    verifyGraph( IUT, 4, 3 );
-    verifyEdges( IUT, makeSet( V1_V2, V2_V4, V1_V3 ));
-    verifyChords(IUT, makeSet( V3_V4 ));
-  }
-
-  public void testMultiplePathR()
-    throws Throwable
-  {
-    MinimumSpanningForest IUT =
-      new MinimumSpanningForest( makeMultiplePathR() );
-    
-    verifyGraph( IUT, 4, 3 );
-    verifyEdges( IUT, makeSet( V1_V3, V3_V4, V2_V4 ));
-    verifyChords(IUT, makeSet( V1_V2 ));
-  }
-
-  public void testMultiplePathEarlyLow()
-    throws Throwable
-  {
-    MinimumSpanningForest IUT =
-      new MinimumSpanningForest( makeMultiplePathEarlyLow() );
-    
-    verifyGraph( IUT, 4, 3 );
-    verifyEdges( IUT, makeSet( V1_V2, V2_V4, V1_V3 ));
-    verifyChords(IUT, makeSet( V3_V4 ));
-  }
-  public void testMaxMultiplePathEarlyLow()
-    throws Throwable
-  {
-    MinimumSpanningForest IUT =
-      new MinimumSpanningForest( false, 
-				 makeMultiplePathEarlyLow() );
-    
-    verifyGraph( IUT, 4, 3 );
-    verifyEdges( IUT, makeSet( V1_V2, V2_V4, V3_V4 ));
-    verifyChords(IUT, makeSet( V1_V3 ));
-  }
-
-  public void testMultiplePathEarlyHigh()
-    throws Throwable
-  {
-    MinimumSpanningForest IUT =
-      new MinimumSpanningForest( makeMultiplePathEarlyHigh() );
-
-    verifyGraph( IUT, 4, 3 );
-    verifyEdges( IUT, makeSet( V1_V2, V2_V4, V3_V4 ) );
-    verifyChords(IUT, makeSet( V1_V3 ));
-  }
-
-  public void testMaxMultiplePathEarlyHigh()
-    throws Throwable
-  {
-    MinimumSpanningForest IUT =
-      new MinimumSpanningForest( false, 
-				 makeMultiplePathEarlyHigh());
-    
-    verifyGraph( IUT, 4, 3 );
-    verifyEdges( IUT, makeSet( V1_V2, V2_V4, V1_V3 ));
-    verifyChords(IUT, makeSet( V3_V4 ));
-  }
-
-  
-  // Helpers. . .
-    
-  public void verifyEdges(Graph g, 
-			  Set edges) throws Throwable {
-    Set gEdges = g.getEdges();
-    assertTrue( "Graph has edges not in expected set.",
-		gEdges.containsAll( edges ));
-    assertTrue( "Graph does not have expected edges.",
-		edges.containsAll( edges ));
-  }
-
-  public void verifyChords(MinimumSpanningForest msf, 
-			  Set chords) throws Throwable {
-    Set gChords = msf.getChords();
-    assertTrue( "Graph has chords not in expected set.",
-		gChords.containsAll( chords ));
-    assertTrue( "Graph does not have expected edges.",
-		chords.containsAll( gChords ));
-  }
-
-}
-
-
-
-
-
+package org.apache.commons.graph.algorithm.spanning;
+
+import java.util.Set;
+
+import org.apache.commons.graph.*;
+import org.apache.commons.graph.exception.*;
+
+public class MinimumSpanningForestTest
+  extends WeightedGraphTest
+{
+  private String name = null;
+
+  public MinimumSpanningForestTest( String name ) {
+    super( name );
+    this.name = name;
+  }
+
+  public void testNullGraph() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeNullGraph();
+    MinimumSpanningForest msf = 
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 0, 0 );
+    verifyChords( msf, makeSet() );
+  }
+  
+  public void testDirNullGraph() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeDirNullGraph();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 0, 0 );
+    verifyChords( msf, makeSet() );
+  }
+
+  public void testSingleVertex() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeSingleVertex();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 1, 0 );
+    verifyChords( msf, makeSet() );
+  }
+
+  public void testDirSingleVertex() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeDirSingleVertex();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 1, 0 );
+    verifyChords( msf, makeSet() );
+  }
+
+  public void testSelfLoop() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeSelfLoop();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 1, 0 );
+
+    verifyChords(msf, makeSet( V1_V1 ));
+  }
+
+  public void testDoubleVertex() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeDoubleVertex();
+    MinimumSpanningForest msf = 
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 2, 0 );
+    verifyChords(msf, makeSet() );
+  }
+
+  public void testDirDoubleVertex() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeDirDoubleVertex();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 2, 0 );
+    verifyChords( msf, makeSet() );
+  }
+
+  public void testSingleEdge() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeSingleEdge();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 2, 1 );
+    verifyChords( msf, makeSet());
+  }
+
+  public void testDirectedEdge() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeDirectedEdge();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 2, 1 );
+    verifyChords( msf, makeSet());
+  }
+
+  public void testParallelEdges() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeParallelEdges();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 2, 1 );
+  }
+
+  public void testDirParallelEdges() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeDirParallelEdges();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 2, 1 );
+  }
+
+  public void testCycle() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeCycle();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 3, 2 );
+  }
+
+  public void testTwoCycle() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeTwoCycle();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 2, 1 );
+  }
+
+  public void testDirectedCycle() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeDirectedCycle();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 3, 2 );
+  }
+
+  public void testNoCycle() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeNoCycle();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 3, 2 );
+  }
+
+  public void testPipe() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makePipe();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 3, 2 );
+  }
+
+  public void testDiamond() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeDiamond();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 4, 3 );
+  }
+
+  public void testPipelessCycle() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makePipelessCycle();
+    MinimumSpanningForest msf =
+      new MinimumSpanningForest( graph );
+    verifyGraph( msf, 4, 3 );
+  }
+
+  public void testHyperGraph() throws Throwable {
+    WeightedGraph graph = (WeightedGraph) makeHyperGraph();
+    try {
+      MinimumSpanningForest msf =
+	new MinimumSpanningForest( graph );
+      fail("HyperGraph Exception not thrown.");
+    } catch (HyperGraphException hge) { }
+  }
+
+  public void testWDirectedEdge()
+    throws Throwable
+  {
+    WeightedGraph graph = makeWDirectedEdge();
+    
+    MinimumSpanningForest msf = 
+      new MinimumSpanningForest( graph );
+    
+    verifyGraph( msf, 2, 1 );
+    verifyEdges( msf, makeSet( V1_V2 ) );
+    assertEquals("Edge Weight not the same.",
+		 5.0, msf.getWeight(V1_V2), 0.00001 );
+    verifyChords( msf, makeSet() );
+  }
+
+  public void testWSelfLoop()
+    throws Throwable
+  {
+    MinimumSpanningForest IUT = 
+      new MinimumSpanningForest( makeWSelfLoop() );
+    verifyGraph(IUT, 1, 0);
+    verifyEdges(IUT, makeSet() );
+    verifyChords(IUT, makeSet( V1_V1 ));
+  }
+
+  public void testPositiveCycle() 
+    throws Throwable
+  {
+    MinimumSpanningForest IUT =
+      new MinimumSpanningForest( makePositiveCycle() );
+    verifyGraph( IUT, 3, 2 );
+    verifyEdges( IUT, makeSet( V3_V1, V1_V2 ));
+    verifyChords( IUT, makeSet( V2_V3 ));
+  }
+
+  public void testPositivePartNegCycle()
+    throws Throwable
+  {
+    MinimumSpanningForest IUT =
+      new MinimumSpanningForest( makePositivePartNegCycle() );
+    verifyGraph( IUT, 3, 2 );
+    verifyEdges( IUT, makeSet( V3_V1, V1_V2 ) );
+    verifyChords( IUT, makeSet( V2_V3 ));
+  }
+
+  public void testNegativeCycle()
+    throws Throwable
+  {
+    MinimumSpanningForest IUT =
+      new MinimumSpanningForest( makeNegativeCycle() );
+    
+    verifyGraph( IUT, 3, 2 );
+    verifyEdges( IUT, makeSet( V2_V3, V1_V2 ));
+    verifyChords( IUT, makeSet( V3_V1 ));
+  }
+
+  public void testNegativePartPosCycle()
+    throws Throwable
+  {
+    MinimumSpanningForest IUT =
+      new MinimumSpanningForest( makeNegativePartPosCycle() );
+    
+    verifyGraph( IUT, 3, 2 );
+    verifyEdges( IUT, makeSet( V2_V3, V1_V2 ));
+    verifyChords( IUT, makeSet( V3_V1 ));
+  }
+
+  public void testPositivePipe()
+    throws Throwable
+  {
+    MinimumSpanningForest IUT =
+      new MinimumSpanningForest( makePositivePipe() );
+    
+    verifyGraph( IUT, 3, 2 );
+    verifyEdges( IUT, makeSet( V1_V2, V2_V3 ));
+    verifyChords(IUT, makeSet());
+  }
+
+  public void testPositivePartNegPipe()
+    throws Throwable
+  {
+    MinimumSpanningForest IUT =
+      new MinimumSpanningForest( makePositivePartNegPipe() );
+    
+    verifyGraph( IUT, 3, 2 );
+    verifyEdges( IUT, makeSet( V1_V2, V2_V3 ));
+    verifyChords(IUT,  makeSet());
+  }
+
+  public void testNegativePipe()
+    throws Throwable
+  {
+    MinimumSpanningForest IUT =
+      new MinimumSpanningForest( makeNegativePipe() );
+    
+    verifyGraph( IUT, 3, 2 );
+    verifyEdges( IUT, makeSet( V1_V2, V2_V3 ));
+    verifyChords(IUT, makeSet());
+  }
+
+  public void testNegativePartPosPipe()
+    throws Throwable
+  {
+    MinimumSpanningForest IUT =
+      new MinimumSpanningForest( makeNegativePartPosPipe() );
+    
+    verifyGraph( IUT, 3, 2 );
+    verifyEdges( IUT, makeSet( V1_V2, V2_V3 ));
+    verifyChords(IUT, makeSet());
+  }
+
+  public void testMultiplePathL()
+    throws Throwable
+  {
+    MinimumSpanningForest IUT =
+      new MinimumSpanningForest( makeMultiplePathL() );
+    
+    verifyGraph( IUT, 4, 3 );
+    verifyEdges( IUT, makeSet( V1_V2, V2_V4, V1_V3 ));
+    verifyChords(IUT, makeSet( V3_V4 ));
+  }
+
+  public void testMultiplePathR()
+    throws Throwable
+  {
+    MinimumSpanningForest IUT =
+      new MinimumSpanningForest( makeMultiplePathR() );
+    
+    verifyGraph( IUT, 4, 3 );
+    verifyEdges( IUT, makeSet( V1_V3, V3_V4, V2_V4 ));
+    verifyChords(IUT, makeSet( V1_V2 ));
+  }
+
+  public void testMultiplePathEarlyLow()
+    throws Throwable
+  {
+    MinimumSpanningForest IUT =
+      new MinimumSpanningForest( makeMultiplePathEarlyLow() );
+    
+    verifyGraph( IUT, 4, 3 );
+    verifyEdges( IUT, makeSet( V1_V2, V2_V4, V1_V3 ));
+    verifyChords(IUT, makeSet( V3_V4 ));
+  }
+  public void testMaxMultiplePathEarlyLow()
+    throws Throwable
+  {
+    MinimumSpanningForest IUT =
+      new MinimumSpanningForest( false, 
+				 makeMultiplePathEarlyLow() );
+    
+    verifyGraph( IUT, 4, 3 );
+    verifyEdges( IUT, makeSet( V1_V2, V2_V4, V3_V4 ));
+    verifyChords(IUT, makeSet( V1_V3 ));
+  }
+
+  public void testMultiplePathEarlyHigh()
+    throws Throwable
+  {
+    MinimumSpanningForest IUT =
+      new MinimumSpanningForest( makeMultiplePathEarlyHigh() );
+
+    verifyGraph( IUT, 4, 3 );
+    verifyEdges( IUT, makeSet( V1_V2, V2_V4, V3_V4 ) );
+    verifyChords(IUT, makeSet( V1_V3 ));
+  }
+
+  public void testMaxMultiplePathEarlyHigh()
+    throws Throwable
+  {
+    MinimumSpanningForest IUT =
+      new MinimumSpanningForest( false, 
+				 makeMultiplePathEarlyHigh());
+    
+    verifyGraph( IUT, 4, 3 );
+    verifyEdges( IUT, makeSet( V1_V2, V2_V4, V1_V3 ));
+    verifyChords(IUT, makeSet( V3_V4 ));
+  }
+
+  
+  // Helpers. . .
+    
+  public void verifyEdges(Graph g, 
+			  Set edges) throws Throwable {
+    Set gEdges = g.getEdges();
+    assertTrue( "Graph has edges not in expected set.",
+		gEdges.containsAll( edges ));
+    assertTrue( "Graph does not have expected edges.",
+		edges.containsAll( edges ));
+  }
+
+  public void verifyChords(MinimumSpanningForest msf, 
+			  Set chords) throws Throwable {
+    Set gChords = msf.getChords();
+    assertTrue( "Graph has chords not in expected set.",
+		gChords.containsAll( chords ));
+    assertTrue( "Graph does not have expected edges.",
+		chords.containsAll( gChords ));
+  }
+
+}
+
+
+
+
+

Propchange: jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/algorithm/spanning/MinimumSpanningForestTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL

Modified: jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/algorithm/util/LabelTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/algorithm/util/LabelTest.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/algorithm/util/LabelTest.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/algorithm/util/LabelTest.java Sat Feb 26 05:21:52 2005
@@ -1,150 +1,150 @@
-package org.apache.commons.graph.algorithm.util;
-
-import junit.framework.*;
-
-public class LabelTest
-  extends TestCase
-{
-  private String testName = null;
-
-  public LabelTest( String testName ) {
-    super( testName );
-    this.testName = testName;
-  }
-
-  private Label L1;
-  private Label L1_;
-  private Label L1__;
-  private Label L2;
-  private Label L3;
-  private Label L4;
-  private Label L5;
-  private Label L6;
-
-  public void setUp() {
-    L1 = new Label();
-    L2 = new Label();
-    L3 = new Label();
-    L4 = new Label();
-    L5 = new Label();
-    L6 = new Label();
-
-    L1_ = new Label( L1 );
-
-    L1__ = new Label( L1_ );
-  }
-
-  public void testDefaultConfig()
-    throws Throwable
-  {
-    assertEquals( L1.getRoot(), L1 );
-    assertEquals( L1_.getRoot(), L1 );
-    assertEquals( L1__.getRoot(), L1 );
-  }
-
-  public void testSetRoot1() 
-    throws Throwable
-  {
-    assertEquals( L1.getRoot(), L1 );
-    assertEquals( L2.getRoot(), L2 );
-
-    L2.setRoot( L1 );
-    assertEquals( L2.getRoot(), L1 );
-  }
-
-  public void testSetRoot2()
-    throws Throwable
-  {
-    assertEquals( L1.getRoot(), L1 );
-    assertEquals( L2.getRoot(), L2 );
-    assertEquals( L3.getRoot(), L3 );
-
-    L3.setRoot( L2 );
-    L2.setRoot( L1 );
-    
-    assertEquals( L3.getRoot(), L1 );
-    assertEquals( L2.getRoot(), L1 );
-    assertEquals( L1.getRoot(), L1 );
-  }
-
-  public void testSetRoot3() 
-    throws Throwable
-  {
-    assertEquals( L1.getRoot(), L1 );
-    assertEquals( L2.getRoot(), L2 );
-    assertEquals( L3.getRoot(), L3 );
-
-    L2.setRoot( L1 );
-    L3.setRoot( L2 );
-
-    assertEquals( L3.getRoot(), L1 );
-    assertEquals( L2.getRoot(), L1 );
-    assertEquals( L1.getRoot(), L1 );
-  }
-
-  public void testSetRoot4()
-    throws Throwable
-  { 
-    assertEquals( L1.getRoot(), L1 );
-    assertEquals( L2.getRoot(), L2 );
-    assertEquals( L3.getRoot(), L3 );
-    assertEquals( L4.getRoot(), L4 );
-
-    L4.setRoot( L3 );
-    L2.setRoot( L1 );
-    L3.setRoot( L1 );
-
-    assertEquals( L4.getRoot(), L1 );
-    assertEquals( L3.getRoot(), L1 );
-    assertEquals( L2.getRoot(), L1 );
-    assertEquals( L1.getRoot(), L1 );
-  }
-
-  public void testSetRootCycle() 
-    throws Throwable
-  {
-    assertEquals( L1.getRoot(), L1 );
-    assertEquals( L2.getRoot(), L2 );
-
-    L1.setRoot( L2 );
-    L2.setRoot( L1 );
-
-    assertEquals( L2.getRoot(), L2 );
-    assertEquals( L1.getRoot(), L2 );
-  }
-
-  public void setDiamond1() throws Throwable {
-    assertEquals( L1.getRoot(), L1 );
-    assertEquals( L2.getRoot(), L2 );
-    assertEquals( L3.getRoot(), L3 );
-    assertEquals( L4.getRoot(), L4 );
-
-    L2.setRoot( L1 );
-    L3.setRoot( L1 );
-    L4.setRoot( L3 );
-
-    assertEquals( L1.getRoot(), L1 );
-    assertEquals( L2.getRoot(), L1 );
-    assertEquals( L3.getRoot(), L1 );
-    assertEquals( L4.getRoot(), L1 );
-  }
-
-  public void setDiamond2() throws Throwable {
-    assertEquals( L1.getRoot(), L1 );
-    assertEquals( L2.getRoot(), L2 );
-    assertEquals( L3.getRoot(), L3 );
-    assertEquals( L4.getRoot(), L4 );
-
-    L4.setRoot( L3 );
-    L2.setRoot( L1 );
-    L3.setRoot( L1 );
-
-    assertEquals( L1.getRoot(), L1 );
-    assertEquals( L2.getRoot(), L1 );
-    assertEquals( L3.getRoot(), L1 );
-    assertEquals( L4.getRoot(), L1 );
-  }
-}
-
-
-
+package org.apache.commons.graph.algorithm.util;
+
+import junit.framework.*;
+
+public class LabelTest
+  extends TestCase
+{
+  private String testName = null;
+
+  public LabelTest( String testName ) {
+    super( testName );
+    this.testName = testName;
+  }
+
+  private Label L1;
+  private Label L1_;
+  private Label L1__;
+  private Label L2;
+  private Label L3;
+  private Label L4;
+  private Label L5;
+  private Label L6;
+
+  public void setUp() {
+    L1 = new Label();
+    L2 = new Label();
+    L3 = new Label();
+    L4 = new Label();
+    L5 = new Label();
+    L6 = new Label();
+
+    L1_ = new Label( L1 );
+
+    L1__ = new Label( L1_ );
+  }
+
+  public void testDefaultConfig()
+    throws Throwable
+  {
+    assertEquals( L1.getRoot(), L1 );
+    assertEquals( L1_.getRoot(), L1 );
+    assertEquals( L1__.getRoot(), L1 );
+  }
+
+  public void testSetRoot1() 
+    throws Throwable
+  {
+    assertEquals( L1.getRoot(), L1 );
+    assertEquals( L2.getRoot(), L2 );
+
+    L2.setRoot( L1 );
+    assertEquals( L2.getRoot(), L1 );
+  }
+
+  public void testSetRoot2()
+    throws Throwable
+  {
+    assertEquals( L1.getRoot(), L1 );
+    assertEquals( L2.getRoot(), L2 );
+    assertEquals( L3.getRoot(), L3 );
+
+    L3.setRoot( L2 );
+    L2.setRoot( L1 );
+    
+    assertEquals( L3.getRoot(), L1 );
+    assertEquals( L2.getRoot(), L1 );
+    assertEquals( L1.getRoot(), L1 );
+  }
+
+  public void testSetRoot3() 
+    throws Throwable
+  {
+    assertEquals( L1.getRoot(), L1 );
+    assertEquals( L2.getRoot(), L2 );
+    assertEquals( L3.getRoot(), L3 );
+
+    L2.setRoot( L1 );
+    L3.setRoot( L2 );
+
+    assertEquals( L3.getRoot(), L1 );
+    assertEquals( L2.getRoot(), L1 );
+    assertEquals( L1.getRoot(), L1 );
+  }
+
+  public void testSetRoot4()
+    throws Throwable
+  { 
+    assertEquals( L1.getRoot(), L1 );
+    assertEquals( L2.getRoot(), L2 );
+    assertEquals( L3.getRoot(), L3 );
+    assertEquals( L4.getRoot(), L4 );
+
+    L4.setRoot( L3 );
+    L2.setRoot( L1 );
+    L3.setRoot( L1 );
+
+    assertEquals( L4.getRoot(), L1 );
+    assertEquals( L3.getRoot(), L1 );
+    assertEquals( L2.getRoot(), L1 );
+    assertEquals( L1.getRoot(), L1 );
+  }
+
+  public void testSetRootCycle() 
+    throws Throwable
+  {
+    assertEquals( L1.getRoot(), L1 );
+    assertEquals( L2.getRoot(), L2 );
+
+    L1.setRoot( L2 );
+    L2.setRoot( L1 );
+
+    assertEquals( L2.getRoot(), L2 );
+    assertEquals( L1.getRoot(), L2 );
+  }
+
+  public void setDiamond1() throws Throwable {
+    assertEquals( L1.getRoot(), L1 );
+    assertEquals( L2.getRoot(), L2 );
+    assertEquals( L3.getRoot(), L3 );
+    assertEquals( L4.getRoot(), L4 );
+
+    L2.setRoot( L1 );
+    L3.setRoot( L1 );
+    L4.setRoot( L3 );
+
+    assertEquals( L1.getRoot(), L1 );
+    assertEquals( L2.getRoot(), L1 );
+    assertEquals( L3.getRoot(), L1 );
+    assertEquals( L4.getRoot(), L1 );
+  }
+
+  public void setDiamond2() throws Throwable {
+    assertEquals( L1.getRoot(), L1 );
+    assertEquals( L2.getRoot(), L2 );
+    assertEquals( L3.getRoot(), L3 );
+    assertEquals( L4.getRoot(), L4 );
+
+    L4.setRoot( L3 );
+    L2.setRoot( L1 );
+    L3.setRoot( L1 );
+
+    assertEquals( L1.getRoot(), L1 );
+    assertEquals( L2.getRoot(), L1 );
+    assertEquals( L3.getRoot(), L1 );
+    assertEquals( L4.getRoot(), L1 );
+  }
+}
+
+
+

Propchange: jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/algorithm/util/LabelTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL

Modified: jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/contract/AcyclicContractTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/contract/AcyclicContractTest.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/contract/AcyclicContractTest.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/contract/AcyclicContractTest.java Sat Feb 26 05:21:52 2005
@@ -1,5 +1,5 @@
-package org.apache.commons.graph.contract;
-
+package org.apache.commons.graph.contract;
+
 /*
  * Copyright 2001,2004 The Apache Software Foundation.
  * 
@@ -14,410 +14,410 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-import org.apache.commons.graph.*;
-import org.apache.commons.graph.exception.*;
-
-/**
- * Description of the Class
- */
-public class AcyclicContractTest
-     extends GraphTest
-{
-    /**
-     * Constructor for the AcyclicContractTest object
-     *
-     * @param name
-     */
-    public AcyclicContractTest(String name)
-    {
-        super(name);
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testDirNullGraph()
-        throws Throwable
-    {
-        AcyclicContract IUT =
-            new AcyclicContract();
-        IUT.setImpl(makeDirNullGraph());
-
-        IUT.verify();
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testDirSingleVertex()
-        throws Throwable
-    {
-        AcyclicContract IUT =
-            new AcyclicContract();
-        IUT.setImpl(makeDirSingleVertex());
-        IUT.verify();
-
-        try
-        {
-            IUT.addEdge(V1_V1, V1, V1);
-            fail("No GraphException thrown when Self-Cycle introduced.");
-        }
-        catch (CycleException ex)
-        {}
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testSelfLoop()
-        throws Throwable
-    {
-        AcyclicContract IUT =
-            new AcyclicContract();
-        IUT.setImpl(makeSelfLoop());
-
-        try
-        {
-            IUT.verify();
-            fail("No CycleException thrown on Verification.");
-        }
-        catch (CycleException ex)
-        {}
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testDirDoubleVertex()
-        throws Throwable
-    {
-        AcyclicContract IUT =
-            new AcyclicContract();
-        IUT.setImpl(makeDirDoubleVertex());
-        IUT.verify();
-
-        try
-        {
-            IUT.addEdge(V1_V1, V1, V1);
-            fail("No GraphException thrown when Self-Cycle introduced.");
-        }
-        catch (CycleException ex)
-        {}
-
-        try
-        {
-            IUT.addEdge(V1_V2, V1, V2);
-        }
-        catch (GraphException ex)
-        {
-            fail("Contract prevented adding of valid edge. V1->V2");
-        }
-    }
-
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testDirectedEdge()
-        throws Throwable
-    {
-        AcyclicContract IUT =
-            new AcyclicContract();
-        IUT.setImpl(makeDirectedEdge());
-        IUT.verify();
-
-        try
-        {
-            IUT.addEdge(V1_V1, V1, V1);
-            fail("No GraphException thrown when Self-Cycle introduced.");
-        }
-        catch (CycleException ex)
-        {}
-
-        try
-        {
-            IUT.addEdge(V1_V2_, V1, V2);
-        }
-        catch (GraphException ex)
-        {
-            fail("Contract prevented adding of valid edge. V1->V2'");
-        }
-
-        try
-        {
-            IUT.addEdge(V2_V1, V2, V1);
-            fail("Contract allowed cycle to be introduced.");
-        }
-        catch (CycleException ex)
-        {}
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testDirParallelEdges()
-        throws Throwable
-    {
-        AcyclicContract IUT =
-            new AcyclicContract();
-        IUT.setImpl(makeDirParallelEdges());
-        IUT.verify();
-
-        try
-        {
-            IUT.addEdge(V1_V1, V1, V1);
-            fail("No GraphException thrown when Self-Cycle introduced.");
-        }
-        catch (CycleException ex)
-        {}
-
-        try
-        {
-            IUT.addEdge(V1_V2__, V1, V2);
-        }
-        catch (GraphException ex)
-        {
-            fail("Contract prevented adding of valid edge. V1->V2'");
-        }
-
-        try
-        {
-            IUT.addEdge(V2_V1, V2, V1);
-            fail("Contract allowed cycle to be introduced.");
-        }
-        catch (CycleException ex)
-        {}
-    }
-
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testTwoCycle()
-        throws Throwable
-    {
-        AcyclicContract IUT =
-            new AcyclicContract();
-        IUT.setImpl(makeTwoCycle());
-
-        try
-        {
-            IUT.verify();
-            fail("No CycleException thrown on Verification.");
-        }
-        catch (CycleException ex)
-        {}
-    }
-
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testDirectedCycle()
-        throws Throwable
-    {
-        AcyclicContract IUT =
-            new AcyclicContract();
-        IUT.setImpl(makeDirectedCycle());
-
-        try
-        {
-            IUT.verify();
-            fail("No CycleException thrown on Verification.");
-        }
-        catch (CycleException ex)
-        {}
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testPipe()
-        throws Throwable
-    {
-        AcyclicContract IUT =
-            new AcyclicContract();
-        IUT.setImpl(makePipe());
-        IUT.verify();
-
-        try
-        {
-            IUT.addEdge(V1_V1, V1, V1);
-            fail("No GraphException thrown when Self-Cycle introduced.");
-        }
-        catch (CycleException ex)
-        {}
-
-        try
-        {
-            IUT.addEdge(V1_V2_, V1, V2);
-        }
-        catch (GraphException ex)
-        {
-            fail("Contract prevented adding of valid edge. V1->V2'");
-        }
-
-        try
-        {
-            IUT.addEdge(V3_V1, V3, V1);
-            fail("Contract allowed cycle to be introduced.");
-        }
-        catch (CycleException ex)
-        {}
-
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testDiamond()
-        throws Throwable
-    {
-        AcyclicContract IUT =
-            new AcyclicContract();
-        IUT.setImpl(makeDiamond());
-        IUT.verify();
-
-        try
-        {
-            IUT.addEdge(V1_V1, V1, V1);
-            fail("No GraphException thrown when Self-Cycle introduced.");
-        }
-        catch (CycleException ex)
-        {}
-
-        try
-        {
-            IUT.addEdge(V2_V3, V2, V3);
-        }
-        catch (GraphException ex)
-        {
-            fail("Contract prevented adding of valid edge. V2->V3");
-        }
-
-        try
-        {
-            IUT.addEdge(V4_V1, V4, V1);
-            fail("Contract allowed cycle to be introduced.");
-        }
-        catch (CycleException ex)
-        {}
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testPipelessCycle()
-        throws Throwable
-    {
-        AcyclicContract IUT =
-            new AcyclicContract();
-        IUT.setImpl(makePipelessCycle());
-        IUT.verify();
-
-        try
-        {
-            IUT.addEdge(V1_V1, V1, V1);
-            fail("No GraphException thrown when Self-Cycle introduced.");
-        }
-        catch (CycleException ex)
-        {}
-
-        try
-        {
-            IUT.addEdge(V2_V3, V2, V3);
-        }
-        catch (GraphException ex)
-        {
-            fail("Contract prevented adding of valid edge. V2->V3");
-        }
-
-        try
-        {
-            IUT.addEdge(V3_V4, V3, V4);
-            fail("Contract allowed cycle to be introduced.");
-        }
-        catch (CycleException ex)
-        {}
-
-    }
-
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testParentTree()
-        throws Throwable
-    {
-        System.err.println("---- PARENT TREE ----");
-        AcyclicContract IUT =
-            new AcyclicContract();
-        IUT.setImpl(makeParentTree());
-        IUT.verify();
-
-        try
-        {
-            IUT.addEdge(V1_V1, V1, V1);
-            fail("No GraphException thrown when Self-Cycle introduced.");
-        }
-        catch (CycleException ex)
-        {}
-
-        try
-        {
-            IUT.addEdge(V2_V3, V2, V3);
-        }
-        catch (GraphException ex)
-        {
-            fail("Contract prevented adding of valid edge. V2->V3");
-        }
-
-        try
-        {
-            IUT.addEdge(V1_V5, V1, V5);
-            fail("Contract allowed cycle to be introduced.");
-        }
-        catch (CycleException ex)
-        {}
-    }
-
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testChildTree()
-        throws Throwable
-    {
-        AcyclicContract IUT =
-            new AcyclicContract();
-        IUT.setImpl(makeChildTree());
-        IUT.verify();
-
-        try
-        {
-            IUT.addEdge(V1_V1, V1, V1);
-            fail("No GraphException thrown when Self-Cycle introduced.");
-        }
-        catch (CycleException ex)
-        {}
-
-        try
-        {
-            IUT.addEdge(V2_V3, V2, V3);
-        }
-        catch (GraphException ex)
-        {
-            fail("Contract prevented adding of valid edge. V2->V3");
-        }
-
-        try
-        {
-            IUT.addEdge(V5_V1, V5, V1);
-            fail("Contract allowed cycle to be introduced.");
-        }
-        catch (CycleException ex)
-        {}
-
-    }
-}
+ */
+import org.apache.commons.graph.*;
+import org.apache.commons.graph.exception.*;
+
+/**
+ * Description of the Class
+ */
+public class AcyclicContractTest
+     extends GraphTest
+{
+    /**
+     * Constructor for the AcyclicContractTest object
+     *
+     * @param name
+     */
+    public AcyclicContractTest(String name)
+    {
+        super(name);
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testDirNullGraph()
+        throws Throwable
+    {
+        AcyclicContract IUT =
+            new AcyclicContract();
+        IUT.setImpl(makeDirNullGraph());
+
+        IUT.verify();
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testDirSingleVertex()
+        throws Throwable
+    {
+        AcyclicContract IUT =
+            new AcyclicContract();
+        IUT.setImpl(makeDirSingleVertex());
+        IUT.verify();
+
+        try
+        {
+            IUT.addEdge(V1_V1, V1, V1);
+            fail("No GraphException thrown when Self-Cycle introduced.");
+        }
+        catch (CycleException ex)
+        {}
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testSelfLoop()
+        throws Throwable
+    {
+        AcyclicContract IUT =
+            new AcyclicContract();
+        IUT.setImpl(makeSelfLoop());
+
+        try
+        {
+            IUT.verify();
+            fail("No CycleException thrown on Verification.");
+        }
+        catch (CycleException ex)
+        {}
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testDirDoubleVertex()
+        throws Throwable
+    {
+        AcyclicContract IUT =
+            new AcyclicContract();
+        IUT.setImpl(makeDirDoubleVertex());
+        IUT.verify();
+
+        try
+        {
+            IUT.addEdge(V1_V1, V1, V1);
+            fail("No GraphException thrown when Self-Cycle introduced.");
+        }
+        catch (CycleException ex)
+        {}
+
+        try
+        {
+            IUT.addEdge(V1_V2, V1, V2);
+        }
+        catch (GraphException ex)
+        {
+            fail("Contract prevented adding of valid edge. V1->V2");
+        }
+    }
+
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testDirectedEdge()
+        throws Throwable
+    {
+        AcyclicContract IUT =
+            new AcyclicContract();
+        IUT.setImpl(makeDirectedEdge());
+        IUT.verify();
+
+        try
+        {
+            IUT.addEdge(V1_V1, V1, V1);
+            fail("No GraphException thrown when Self-Cycle introduced.");
+        }
+        catch (CycleException ex)
+        {}
+
+        try
+        {
+            IUT.addEdge(V1_V2_, V1, V2);
+        }
+        catch (GraphException ex)
+        {
+            fail("Contract prevented adding of valid edge. V1->V2'");
+        }
+
+        try
+        {
+            IUT.addEdge(V2_V1, V2, V1);
+            fail("Contract allowed cycle to be introduced.");
+        }
+        catch (CycleException ex)
+        {}
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testDirParallelEdges()
+        throws Throwable
+    {
+        AcyclicContract IUT =
+            new AcyclicContract();
+        IUT.setImpl(makeDirParallelEdges());
+        IUT.verify();
+
+        try
+        {
+            IUT.addEdge(V1_V1, V1, V1);
+            fail("No GraphException thrown when Self-Cycle introduced.");
+        }
+        catch (CycleException ex)
+        {}
+
+        try
+        {
+            IUT.addEdge(V1_V2__, V1, V2);
+        }
+        catch (GraphException ex)
+        {
+            fail("Contract prevented adding of valid edge. V1->V2'");
+        }
+
+        try
+        {
+            IUT.addEdge(V2_V1, V2, V1);
+            fail("Contract allowed cycle to be introduced.");
+        }
+        catch (CycleException ex)
+        {}
+    }
+
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testTwoCycle()
+        throws Throwable
+    {
+        AcyclicContract IUT =
+            new AcyclicContract();
+        IUT.setImpl(makeTwoCycle());
+
+        try
+        {
+            IUT.verify();
+            fail("No CycleException thrown on Verification.");
+        }
+        catch (CycleException ex)
+        {}
+    }
+
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testDirectedCycle()
+        throws Throwable
+    {
+        AcyclicContract IUT =
+            new AcyclicContract();
+        IUT.setImpl(makeDirectedCycle());
+
+        try
+        {
+            IUT.verify();
+            fail("No CycleException thrown on Verification.");
+        }
+        catch (CycleException ex)
+        {}
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testPipe()
+        throws Throwable
+    {
+        AcyclicContract IUT =
+            new AcyclicContract();
+        IUT.setImpl(makePipe());
+        IUT.verify();
+
+        try
+        {
+            IUT.addEdge(V1_V1, V1, V1);
+            fail("No GraphException thrown when Self-Cycle introduced.");
+        }
+        catch (CycleException ex)
+        {}
+
+        try
+        {
+            IUT.addEdge(V1_V2_, V1, V2);
+        }
+        catch (GraphException ex)
+        {
+            fail("Contract prevented adding of valid edge. V1->V2'");
+        }
+
+        try
+        {
+            IUT.addEdge(V3_V1, V3, V1);
+            fail("Contract allowed cycle to be introduced.");
+        }
+        catch (CycleException ex)
+        {}
+
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testDiamond()
+        throws Throwable
+    {
+        AcyclicContract IUT =
+            new AcyclicContract();
+        IUT.setImpl(makeDiamond());
+        IUT.verify();
+
+        try
+        {
+            IUT.addEdge(V1_V1, V1, V1);
+            fail("No GraphException thrown when Self-Cycle introduced.");
+        }
+        catch (CycleException ex)
+        {}
+
+        try
+        {
+            IUT.addEdge(V2_V3, V2, V3);
+        }
+        catch (GraphException ex)
+        {
+            fail("Contract prevented adding of valid edge. V2->V3");
+        }
+
+        try
+        {
+            IUT.addEdge(V4_V1, V4, V1);
+            fail("Contract allowed cycle to be introduced.");
+        }
+        catch (CycleException ex)
+        {}
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testPipelessCycle()
+        throws Throwable
+    {
+        AcyclicContract IUT =
+            new AcyclicContract();
+        IUT.setImpl(makePipelessCycle());
+        IUT.verify();
+
+        try
+        {
+            IUT.addEdge(V1_V1, V1, V1);
+            fail("No GraphException thrown when Self-Cycle introduced.");
+        }
+        catch (CycleException ex)
+        {}
+
+        try
+        {
+            IUT.addEdge(V2_V3, V2, V3);
+        }
+        catch (GraphException ex)
+        {
+            fail("Contract prevented adding of valid edge. V2->V3");
+        }
+
+        try
+        {
+            IUT.addEdge(V3_V4, V3, V4);
+            fail("Contract allowed cycle to be introduced.");
+        }
+        catch (CycleException ex)
+        {}
+
+    }
+
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testParentTree()
+        throws Throwable
+    {
+        System.err.println("---- PARENT TREE ----");
+        AcyclicContract IUT =
+            new AcyclicContract();
+        IUT.setImpl(makeParentTree());
+        IUT.verify();
+
+        try
+        {
+            IUT.addEdge(V1_V1, V1, V1);
+            fail("No GraphException thrown when Self-Cycle introduced.");
+        }
+        catch (CycleException ex)
+        {}
+
+        try
+        {
+            IUT.addEdge(V2_V3, V2, V3);
+        }
+        catch (GraphException ex)
+        {
+            fail("Contract prevented adding of valid edge. V2->V3");
+        }
+
+        try
+        {
+            IUT.addEdge(V1_V5, V1, V5);
+            fail("Contract allowed cycle to be introduced.");
+        }
+        catch (CycleException ex)
+        {}
+    }
+
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testChildTree()
+        throws Throwable
+    {
+        AcyclicContract IUT =
+            new AcyclicContract();
+        IUT.setImpl(makeChildTree());
+        IUT.verify();
+
+        try
+        {
+            IUT.addEdge(V1_V1, V1, V1);
+            fail("No GraphException thrown when Self-Cycle introduced.");
+        }
+        catch (CycleException ex)
+        {}
+
+        try
+        {
+            IUT.addEdge(V2_V3, V2, V3);
+        }
+        catch (GraphException ex)
+        {
+            fail("Contract prevented adding of valid edge. V2->V3");
+        }
+
+        try
+        {
+            IUT.addEdge(V5_V1, V5, V1);
+            fail("Contract allowed cycle to be introduced.");
+        }
+        catch (CycleException ex)
+        {}
+
+    }
+}

Propchange: jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/contract/AcyclicContractTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL

Modified: jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/contract/DAGTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/contract/DAGTest.java?view=diff&r1=155446&r2=155447
==============================================================================
--- jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/contract/DAGTest.java (original)
+++ jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/contract/DAGTest.java Sat Feb 26 05:21:52 2005
@@ -1,275 +1,275 @@
-package org.apache.commons.graph.contract;
-
-/**
- * DAGTest This test looks to verify that yes indeed contracts are being called
- * when created through the GraphFactory.
- */
-
-import org.apache.commons.graph.*;
-import org.apache.commons.graph.contract.*;
-import org.apache.commons.graph.exception.*;
-import org.apache.commons.graph.factory.*;
-
-/**
- * Description of the Class
- */
-public class DAGTest
-     extends GraphTest
-{
-    private Contract[] dagContracts = new Contract[1];
-    private GraphFactory factory = new GraphFactory();
-    private String testName = null;
-
-    /**
-     * Constructor for the DAGTest object
-     *
-     * @param name
-     */
-    public DAGTest(String name)
-    {
-        super(name);
-        this.testName = name;
-    }
-
-    /**
-     * The JUnit setup method
-     */
-    public void setUp()
-    {
-        dagContracts[0] = new AcyclicContract();
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testDAGSelfLoop()
-        throws Throwable
-    {
-        DirectedGraph dg = null;
-        try
-        {
-            try
-            {
-                dg = factory.makeDirectedGraph(dagContracts,
-                    true,
-                    makeSelfLoop());
-                fail("Should not have created DAG.");
-            }
-            catch (CycleException ex)
-            {}
-        }
-        catch (Throwable ex)
-        {
-            printGraph(ex, dg);
-            throw ex;
-        }
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testDAGTwoLoop()
-        throws Throwable
-    {
-        DirectedGraph dg = null;
-        try
-        {
-            try
-            {
-                dg = factory.makeDirectedGraph(dagContracts,
-                    true,
-                    makeTwoCycle());
-                fail("Should not have created DAG.");
-            }
-            catch (CycleException ex)
-            {}
-        }
-        catch (Throwable ex)
-        {
-            printGraph(ex, dg);
-            throw ex;
-        }
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testMakeDAGDirCycle()
-        throws Throwable
-    {
-        MutableDirectedGraph mdg = null;
-        try
-        {
-            mdg = factory.makeMutableDirectedGraph(dagContracts,
-                true,
-                null);
-            mdg.addVertex(V1);
-            mdg.addVertex(V2);
-            mdg.addEdge(V1_V2, V1, V2);
-
-            mdg.addVertex(V3);
-            mdg.addEdge(V2_V3, V2, V3);
-
-            try
-            {
-                mdg.addEdge(V3_V1, V3, V1);
-                fail("No CycleException thrown on introduction of cycle.");
-            }
-            catch (CycleException ex)
-            {}
-        }
-        catch (Throwable t)
-        {
-            printGraph(t, mdg);
-        }
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testDAGDirCycle()
-        throws Throwable
-    {
-        DirectedGraph dg = null;
-        try
-        {
-            try
-            {
-                dg = factory.makeDirectedGraph(dagContracts,
-                    true,
-                    makeDirectedCycle());
-                fail("Should not have created DAG.");
-            }
-            catch (CycleException ex)
-            {}
-        }
-        catch (Throwable ex)
-        {
-            printGraph(ex, dg);
-            throw ex;
-        }
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testDAGAddCycleToPipe()
-        throws Throwable
-    {
-        MutableDirectedGraph mdg = null;
-        try
-        {
-            try
-            {
-                mdg = factory.makeMutableDirectedGraph(dagContracts,
-                    true,
-                    makePipe());
-                mdg.addEdge(V3_V1, V3, V1);
-                fail("No Exception thrown on adding of invalid edge.");
-            }
-            catch (CycleException e)
-            {}
-        }
-        catch (Throwable ex)
-        {
-            printGraph(ex, mdg);
-            throw ex;
-        }
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testDAGAddCycleToDirEdge()
-        throws Throwable
-    {
-        MutableDirectedGraph mdg = null;
-        try
-        {
-            try
-            {
-                mdg = factory.makeMutableDirectedGraph(dagContracts,
-                    true,
-                    makeDirectedEdge());
-                mdg.addEdge(V2_V1, V2, V1);
-                fail("Failed to throw exception on introducing Cycle.");
-            }
-            catch (CycleException ex)
-            {}
-        }
-        catch (Throwable ex)
-        {
-            printGraph(ex, mdg);
-            throw ex;
-        }
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testDAGAddSelfLoop()
-        throws Throwable
-    {
-        MutableDirectedGraph mdg = null;
-        try
-        {
-            try
-            {
-                mdg = factory.makeMutableDirectedGraph(dagContracts,
-                    true,
-                    makeDirSingleVertex());
-                mdg.addEdge(V1_V1, V1, V1);
-                fail("Failed to throw exception on introducing Self Loop.");
-            }
-            catch (CycleException ex)
-            {}
-        }
-        catch (Throwable ex)
-        {
-            printGraph(ex, mdg);
-            throw ex;
-        }
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testDAGValidEdge()
-        throws Throwable
-    {
-        MutableDirectedGraph mdg = null;
-        try
-        {
-            mdg = factory.makeMutableDirectedGraph(dagContracts,
-                true,
-                makeParentTree());
-            mdg.addEdge(V2_V3, V2, V3);
-        }
-        catch (Throwable ex)
-        {
-            printGraph(ex, mdg);
-            throw ex;
-        }
-    }
-
-    /**
-     * A unit test for JUnit
-     */
-    public void testDAGValidEdge2()
-        throws Throwable
-    {
-        MutableDirectedGraph mdg = null;
-        try
-        {
-            mdg = factory.makeMutableDirectedGraph(dagContracts,
-                true,
-                makeDirDoubleVertex());
-            mdg.addEdge(V1_V2, V1, V2);
-        }
-        catch (Throwable ex)
-        {
-            printGraph(ex, mdg);
-            throw ex;
-        }
-    }
-}
+package org.apache.commons.graph.contract;
+
+/**
+ * DAGTest This test looks to verify that yes indeed contracts are being called
+ * when created through the GraphFactory.
+ */
+
+import org.apache.commons.graph.*;
+import org.apache.commons.graph.contract.*;
+import org.apache.commons.graph.exception.*;
+import org.apache.commons.graph.factory.*;
+
+/**
+ * Description of the Class
+ */
+public class DAGTest
+     extends GraphTest
+{
+    private Contract[] dagContracts = new Contract[1];
+    private GraphFactory factory = new GraphFactory();
+    private String testName = null;
+
+    /**
+     * Constructor for the DAGTest object
+     *
+     * @param name
+     */
+    public DAGTest(String name)
+    {
+        super(name);
+        this.testName = name;
+    }
+
+    /**
+     * The JUnit setup method
+     */
+    public void setUp()
+    {
+        dagContracts[0] = new AcyclicContract();
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testDAGSelfLoop()
+        throws Throwable
+    {
+        DirectedGraph dg = null;
+        try
+        {
+            try
+            {
+                dg = factory.makeDirectedGraph(dagContracts,
+                    true,
+                    makeSelfLoop());
+                fail("Should not have created DAG.");
+            }
+            catch (CycleException ex)
+            {}
+        }
+        catch (Throwable ex)
+        {
+            printGraph(ex, dg);
+            throw ex;
+        }
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testDAGTwoLoop()
+        throws Throwable
+    {
+        DirectedGraph dg = null;
+        try
+        {
+            try
+            {
+                dg = factory.makeDirectedGraph(dagContracts,
+                    true,
+                    makeTwoCycle());
+                fail("Should not have created DAG.");
+            }
+            catch (CycleException ex)
+            {}
+        }
+        catch (Throwable ex)
+        {
+            printGraph(ex, dg);
+            throw ex;
+        }
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testMakeDAGDirCycle()
+        throws Throwable
+    {
+        MutableDirectedGraph mdg = null;
+        try
+        {
+            mdg = factory.makeMutableDirectedGraph(dagContracts,
+                true,
+                null);
+            mdg.addVertex(V1);
+            mdg.addVertex(V2);
+            mdg.addEdge(V1_V2, V1, V2);
+
+            mdg.addVertex(V3);
+            mdg.addEdge(V2_V3, V2, V3);
+
+            try
+            {
+                mdg.addEdge(V3_V1, V3, V1);
+                fail("No CycleException thrown on introduction of cycle.");
+            }
+            catch (CycleException ex)
+            {}
+        }
+        catch (Throwable t)
+        {
+            printGraph(t, mdg);
+        }
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testDAGDirCycle()
+        throws Throwable
+    {
+        DirectedGraph dg = null;
+        try
+        {
+            try
+            {
+                dg = factory.makeDirectedGraph(dagContracts,
+                    true,
+                    makeDirectedCycle());
+                fail("Should not have created DAG.");
+            }
+            catch (CycleException ex)
+            {}
+        }
+        catch (Throwable ex)
+        {
+            printGraph(ex, dg);
+            throw ex;
+        }
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testDAGAddCycleToPipe()
+        throws Throwable
+    {
+        MutableDirectedGraph mdg = null;
+        try
+        {
+            try
+            {
+                mdg = factory.makeMutableDirectedGraph(dagContracts,
+                    true,
+                    makePipe());
+                mdg.addEdge(V3_V1, V3, V1);
+                fail("No Exception thrown on adding of invalid edge.");
+            }
+            catch (CycleException e)
+            {}
+        }
+        catch (Throwable ex)
+        {
+            printGraph(ex, mdg);
+            throw ex;
+        }
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testDAGAddCycleToDirEdge()
+        throws Throwable
+    {
+        MutableDirectedGraph mdg = null;
+        try
+        {
+            try
+            {
+                mdg = factory.makeMutableDirectedGraph(dagContracts,
+                    true,
+                    makeDirectedEdge());
+                mdg.addEdge(V2_V1, V2, V1);
+                fail("Failed to throw exception on introducing Cycle.");
+            }
+            catch (CycleException ex)
+            {}
+        }
+        catch (Throwable ex)
+        {
+            printGraph(ex, mdg);
+            throw ex;
+        }
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testDAGAddSelfLoop()
+        throws Throwable
+    {
+        MutableDirectedGraph mdg = null;
+        try
+        {
+            try
+            {
+                mdg = factory.makeMutableDirectedGraph(dagContracts,
+                    true,
+                    makeDirSingleVertex());
+                mdg.addEdge(V1_V1, V1, V1);
+                fail("Failed to throw exception on introducing Self Loop.");
+            }
+            catch (CycleException ex)
+            {}
+        }
+        catch (Throwable ex)
+        {
+            printGraph(ex, mdg);
+            throw ex;
+        }
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testDAGValidEdge()
+        throws Throwable
+    {
+        MutableDirectedGraph mdg = null;
+        try
+        {
+            mdg = factory.makeMutableDirectedGraph(dagContracts,
+                true,
+                makeParentTree());
+            mdg.addEdge(V2_V3, V2, V3);
+        }
+        catch (Throwable ex)
+        {
+            printGraph(ex, mdg);
+            throw ex;
+        }
+    }
+
+    /**
+     * A unit test for JUnit
+     */
+    public void testDAGValidEdge2()
+        throws Throwable
+    {
+        MutableDirectedGraph mdg = null;
+        try
+        {
+            mdg = factory.makeMutableDirectedGraph(dagContracts,
+                true,
+                makeDirDoubleVertex());
+            mdg.addEdge(V1_V2, V1, V2);
+        }
+        catch (Throwable ex)
+        {
+            printGraph(ex, mdg);
+            throw ex;
+        }
+    }
+}

Propchange: jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/contract/DAGTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL

Propchange: jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/decorator/ShortestPathTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL

Propchange: jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/decorator/TransposeTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL

Propchange: jakarta/commons/sandbox/graph2/trunk/src/test/org/apache/commons/graph/domain/dependency/DependencyTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL

Propchange: jakarta/commons/sandbox/graph2/trunk/xdocs/project.xml
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Sat Feb 26 05:21:52 2005
@@ -1 +1 @@
-author date id revision
+Date Author Id Revision HeadURL



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org