Author: marcosperanza
Date: Tue Feb 14 22:08:26 2012
New Revision: 1244234
URL: http://svn.apache.org/viewvc?rev=1244234&view=rev
Log:
Added test cases
Added PathNotFoundException into PredecessorList
Modified:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultTargetSourceSelector.java
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/PredecessorsList.java
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/flow/EdmondsKarpTestCase.java
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/AStarTestCase.java
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/BellmannFordTestCase.java
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/DijkstraTestCase.java
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/FloydWarshallTestCase.java
Modified:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultTargetSourceSelector.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultTargetSourceSelector.java?rev=1244234&r1=1244233&r2=1244234&view=diff
==============================================================================
---
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultTargetSourceSelector.java
(original)
+++
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultTargetSourceSelector.java
Tue Feb 14 22:08:26 2012
@@ -105,8 +105,12 @@ final class DefaultTargetSourceSelector<
{
if ( !source.equals( target ) )
{
- WeightedPath<V, WE, W> weightedPath = predecessors.buildPath(
source, target );
- allVertexPairsShortestPath.addShortestPath( source, target,
weightedPath );
+ try{
+ WeightedPath<V, WE, W> weightedPath =
predecessors.buildPath( source, target );
+ allVertexPairsShortestPath.addShortestPath( source,
target, weightedPath );
+ }catch (PathNotFoundException e) {
+ continue;
+ }
}
}
Modified:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/PredecessorsList.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/PredecessorsList.java?rev=1244234&r1=1244233&r2=1244234&view=diff
==============================================================================
---
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/PredecessorsList.java
(original)
+++
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/PredecessorsList.java
Tue Feb 14 22:08:26 2012
@@ -22,6 +22,7 @@ package org.apache.commons.graph.shortes
import java.util.HashMap;
import java.util.Map;
+import org.apache.commons.graph.Edge;
import org.apache.commons.graph.Graph;
import org.apache.commons.graph.Vertex;
import org.apache.commons.graph.WeightedEdge;
@@ -79,6 +80,10 @@ public final class PredecessorsList<V ex
while ( !source.equals( vertex ) )
{
V predecessor = predecessors.get( vertex );
+ if ( predecessor == null )
+ {
+ throw new PathNotFoundException( "Path from '%s' to '%s'
doesn't exist", source, target );
+ }
WE edge = graph.getEdge( predecessor, vertex );
path.addConnectionInHead( predecessor, edge, vertex );
Modified:
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/flow/EdmondsKarpTestCase.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/flow/EdmondsKarpTestCase.java?rev=1244234&r1=1244233&r2=1244234&view=diff
==============================================================================
---
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/flow/EdmondsKarpTestCase.java
(original)
+++
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/flow/EdmondsKarpTestCase.java
Tue Feb 14 22:08:26 2012
@@ -19,6 +19,13 @@ package org.apache.commons.graph.flow;
* under the License.
*/
+import static org.apache.commons.graph.CommonsGraph.findMaxFlow;
+import static
org.apache.commons.graph.CommonsGraph.newDirectedMutableWeightedGraph;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.apache.commons.graph.Vertex;
+import org.apache.commons.graph.WeightedEdge;
import org.apache.commons.graph.builder.AbstractGraphConnection;
import org.apache.commons.graph.model.BaseLabeledVertex;
import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
@@ -26,10 +33,6 @@ import org.apache.commons.graph.model.Di
import org.apache.commons.graph.weight.primitive.IntegerWeight;
import org.junit.Test;
-import static org.apache.commons.graph.CommonsGraph.findMaxFlow;
-import static
org.apache.commons.graph.CommonsGraph.newDirectedMutableWeightedGraph;
-import static org.junit.Assert.assertEquals;
-
/**
* Test for Edmonds-Karp algorithm implementation.
* The test graph is available on
@@ -37,6 +40,73 @@ import static org.junit.Assert.assertEqu
*/
public class EdmondsKarpTestCase
{
+
+ @Test( expected = NullPointerException.class )
+ public void testNullGraph()
+ {
+ final BaseLabeledVertex a = new BaseLabeledVertex( "A" );
+ final BaseLabeledVertex g = new BaseLabeledVertex( "G" );
+
+ // actual max flow
+ findMaxFlow( (DirectedMutableWeightedGraph<Vertex,
WeightedEdge<Integer>, Integer>) null ).from( a ).to( g ).applyingEdmondsKarp(
new IntegerWeight() );
+ fail( "Null Pointer Exception not catched" );
+ }
+
+ @Test( expected = NullPointerException.class )
+ public void testNullVertices()
+ {
+
+ final BaseLabeledVertex a = null;
+ final BaseLabeledVertex g = null;
+
+ DirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Integer>, Integer> graph =
+ newDirectedMutableWeightedGraph( new
AbstractGraphConnection<BaseLabeledVertex, BaseLabeledWeightedEdge<Integer>>()
+ {
+ @Override
+ public void connect()
+ {
+ }
+
+ } );
+
+ // actual max flow
+ findMaxFlow( graph ).from( a ).to( g ).applyingEdmondsKarp( new
IntegerWeight() );
+ fail( "Null Pointer Exception not catched" );
+ }
+
+ @Test
+ public void testSparse()
+ {
+ final BaseLabeledVertex a = new BaseLabeledVertex( "A" );
+ final BaseLabeledVertex g = new BaseLabeledVertex( "G" );
+
+ DirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Integer>, Integer> graph =
+ newDirectedMutableWeightedGraph( new
AbstractGraphConnection<BaseLabeledVertex, BaseLabeledWeightedEdge<Integer>>()
+ {
+
+ @Override
+ public void connect()
+ {
+ addVertex( a );
+ BaseLabeledVertex b = addVertex( new BaseLabeledVertex(
"B" ) );
+ BaseLabeledVertex c = addVertex( new BaseLabeledVertex(
"C" ) );
+ addVertex( new BaseLabeledVertex( "D" ) );
+ addVertex( new BaseLabeledVertex( "E" ) );
+ addVertex( new BaseLabeledVertex( "F" ) );
+ addVertex( g );
+
+ addEdge( new BaseLabeledWeightedEdge<Integer>( "A -> B", 3
) ).from( a ).to( b );
+ addEdge( new BaseLabeledWeightedEdge<Integer>( "B -> C", 4
) ).from( b ).to( c );
+ }
+ } );
+
+ // expected max flow
+ final Integer expected = 0;
+
+ // actual max flow
+ Integer actual = findMaxFlow( graph ).from( a ).to( g
).applyingEdmondsKarp( new IntegerWeight() );
+ assertEquals( actual, expected );
+ }
@Test
public void findMaxFlowAndVerify()
Modified:
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/AStarTestCase.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/AStarTestCase.java?rev=1244234&r1=1244233&r2=1244234&view=diff
==============================================================================
---
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/AStarTestCase.java
(original)
+++
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/AStarTestCase.java
Tue Feb 14 22:08:26 2012
@@ -21,11 +21,15 @@ package org.apache.commons.graph.shortes
import static junit.framework.Assert.assertEquals;
import static org.apache.commons.graph.CommonsGraph.findShortestPath;
+import static org.junit.Assert.fail;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.graph.Path;
+import org.apache.commons.graph.Vertex;
+import org.apache.commons.graph.WeightedEdge;
+import org.apache.commons.graph.WeightedGraph;
import org.apache.commons.graph.model.BaseLabeledVertex;
import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
import org.apache.commons.graph.model.InMemoryWeightedPath;
@@ -36,6 +40,87 @@ import org.junit.Test;
public final class AStarTestCase
{
+ @Test( expected = NullPointerException.class )
+ public void testNullGraah()
+ {
+ findShortestPath( (WeightedGraph<Vertex, WeightedEdge<Double>,
Double>) null ).from( null ).to( null ).applyingAStar( new DoubleWeight()
).withHeuristic( null );
+ fail( "Null Pointer Exception not catched" );
+ }
+
+ @Test( expected = NullPointerException.class )
+ public void testNullVertices()
+ {
+ UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> graph =
+ new UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double>();
+
+ findShortestPath( graph ).from( null ).to( null ).applyingAStar( new
DoubleWeight() ).withHeuristic( null );
+ fail( "Null Pointer Exception not catched" );
+ }
+
+ @Test( expected = NullPointerException.class )
+ public void testNullHeuristic()
+ {
+ UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> graph =
+ new UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double>();
+
+ findShortestPath( graph ).from( new BaseLabeledVertex( "a" ) ).to( new
BaseLabeledVertex( "b" ) ).applyingAStar( new DoubleWeight() ).withHeuristic(
null );
+ fail( "Null Pointer Exception not catched" );
+ }
+
+ @Test( expected = NullPointerException.class )
+ public void testNullMonoid()
+ {
+ UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> graph =
+ new UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double>();
+
+ final BaseLabeledVertex a = new BaseLabeledVertex( "a" );
+ final BaseLabeledVertex b = new BaseLabeledVertex( "b" );
+ graph.addVertex( a );
+ graph.addVertex( b );
+
+ final Map<BaseLabeledVertex, Double> heuristics = new
HashMap<BaseLabeledVertex, Double>();
+
+ Heuristic<BaseLabeledVertex, Double> heuristic = new
Heuristic<BaseLabeledVertex, Double>()
+ {
+
+ public Double applyHeuristic( BaseLabeledVertex current,
BaseLabeledVertex goal )
+ {
+ return heuristics.get( current );
+ }
+
+ };
+
+ findShortestPath( graph ).from( a ).to( b ).applyingAStar( null
).withHeuristic( heuristic );
+ fail( "Null Pointer Exception not catched" );
+ }
+
+ @Test( expected = PathNotFoundException.class )
+ public void testNotConnectGraph()
+ {
+ UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> graph =
+ new UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double>();
+
+ final BaseLabeledVertex a = new BaseLabeledVertex( "a" );
+ final BaseLabeledVertex b = new BaseLabeledVertex( "b" );
+ graph.addVertex( a );
+ graph.addVertex( b );
+
+ final Map<BaseLabeledVertex, Double> heuristics = new
HashMap<BaseLabeledVertex, Double>();
+
+ Heuristic<BaseLabeledVertex, Double> heuristic = new
Heuristic<BaseLabeledVertex, Double>()
+ {
+
+ public Double applyHeuristic( BaseLabeledVertex current,
BaseLabeledVertex goal )
+ {
+ return heuristics.get( current );
+ }
+
+ };
+
+ findShortestPath( graph ).from( a ).to( b ).applyingAStar( new
DoubleWeight() ).withHeuristic( heuristic );
+ fail( "Path not found Exception not cathed" );
+ }
+
/**
* Test Graph and Dijkstra's solution can be seen on
* <a href="http://en.wikipedia.org/wiki/A*_search_algorithm">Wikipedia</a>
Modified:
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/BellmannFordTestCase.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/BellmannFordTestCase.java?rev=1244234&r1=1244233&r2=1244234&view=diff
==============================================================================
---
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/BellmannFordTestCase.java
(original)
+++
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/BellmannFordTestCase.java
Tue Feb 14 22:08:26 2012
@@ -19,20 +19,84 @@ package org.apache.commons.graph.shortes
* under the License.
*/
-import static org.apache.commons.graph.CommonsGraph.findShortestPath;
import static junit.framework.Assert.assertEquals;
+import static org.apache.commons.graph.CommonsGraph.findShortestPath;
+import static org.junit.Assert.fail;
+import org.apache.commons.graph.Vertex;
+import org.apache.commons.graph.WeightedEdge;
+import org.apache.commons.graph.WeightedGraph;
import org.apache.commons.graph.WeightedPath;
import org.apache.commons.graph.model.BaseLabeledVertex;
import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
import org.apache.commons.graph.model.DirectedMutableWeightedGraph;
import org.apache.commons.graph.model.InMemoryWeightedPath;
+import org.apache.commons.graph.model.UndirectedMutableWeightedGraph;
import org.apache.commons.graph.weight.primitive.DoubleWeight;
import org.junit.Test;
public final class BellmannFordTestCase
{
+ @Test( expected = NullPointerException.class )
+ public void testNullGraah()
+ {
+ // the actual weighted path
+ findShortestPath( (WeightedGraph<Vertex, WeightedEdge<Double>,
Double>) null ).from( null ).applyingBelmannFord( new DoubleWeight() );
+ fail( "Null Pointer Exception not catched" );
+ }
+
+ @Test( expected = NullPointerException.class )
+ public void testNullVertices()
+ {
+ UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> graph =
+ new UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double>();
+
+ // the actual weighted path
+ AllVertexPairsShortestPath<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> allVertexPairsShortestPath =
+ findShortestPath( graph ).from( null ).applyingBelmannFord( new
DoubleWeight() );
+
+ allVertexPairsShortestPath.findShortestPath( null, null );
+ fail( "Null Pointer Exception not catched" );
+ }
+
+ @Test( expected = NullPointerException.class )
+ public void testNullMonoid()
+ {
+ UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> graph =
+ new UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double>();
+
+ final BaseLabeledVertex a = new BaseLabeledVertex( "a" );
+ final BaseLabeledVertex b = new BaseLabeledVertex( "b" );
+ graph.addVertex( a );
+ graph.addVertex( b );
+
+ // the actual weighted path
+ AllVertexPairsShortestPath<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> allVertexPairsShortestPath =
+ findShortestPath( graph ).from( a ).applyingBelmannFord( null );
+
+ allVertexPairsShortestPath.findShortestPath( a, b );
+ fail( "Null Pointer Exception not catched" );
+ }
+
+ @Test( expected = PathNotFoundException.class )
+ public void testNotConnectGraph()
+ {
+ UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> graph =
+ new UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double>();
+
+ final BaseLabeledVertex a = new BaseLabeledVertex( "a" );
+ final BaseLabeledVertex b = new BaseLabeledVertex( "b" );
+ graph.addVertex( a );
+ graph.addVertex( b );
+
+ // the actual weighted path
+ AllVertexPairsShortestPath<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> allVertexPairsShortestPath =
+ findShortestPath( graph ).from( a ).applyingBelmannFord( new
DoubleWeight() );
+
+ allVertexPairsShortestPath.findShortestPath( a, b );
+ }
+
/**
* Test Graph and Dijkstra's solution can be seen on
* <a
href="http://compprog.wordpress.com/2007/11/29/one-source-shortest-path-the-bellman-ford-algorithm/">Wikipedia</a>
Modified:
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/DijkstraTestCase.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/DijkstraTestCase.java?rev=1244234&r1=1244233&r2=1244234&view=diff
==============================================================================
---
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/DijkstraTestCase.java
(original)
+++
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/DijkstraTestCase.java
Tue Feb 14 22:08:26 2012
@@ -21,18 +21,75 @@ package org.apache.commons.graph.shortes
import static junit.framework.Assert.assertEquals;
import static org.apache.commons.graph.CommonsGraph.findShortestPath;
+import static org.junit.Assert.fail;
import org.apache.commons.graph.Path;
+import org.apache.commons.graph.Vertex;
+import org.apache.commons.graph.WeightedEdge;
+import org.apache.commons.graph.WeightedGraph;
import org.apache.commons.graph.model.BaseLabeledVertex;
import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
import org.apache.commons.graph.model.DirectedMutableWeightedGraph;
import org.apache.commons.graph.model.InMemoryWeightedPath;
+import org.apache.commons.graph.model.UndirectedMutableWeightedGraph;
import org.apache.commons.graph.weight.primitive.DoubleWeight;
import org.junit.Test;
public final class DijkstraTestCase
{
+ @Test( expected = NullPointerException.class )
+ public void testNullGraah()
+ {
+ // the actual weighted path
+ findShortestPath( (WeightedGraph<Vertex, WeightedEdge<Double>,
Double>) null ).from( null ).to( null ).applyingDijkstra( new DoubleWeight() );
+ fail( "Null Pointer Exception not catched" );
+ }
+
+ @Test( expected = NullPointerException.class )
+ public void testNullVertices()
+ {
+ UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> graph =
+ new UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double>();
+
+ // the actual weighted path
+ findShortestPath( graph ).from( null ).to( null ).applyingDijkstra(
new DoubleWeight() );
+
+ fail( "Null Pointer Exception not catched" );
+ }
+
+ @Test( expected = NullPointerException.class )
+ public void testNullMonoid()
+ {
+ UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> graph =
+ new UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double>();
+
+ final BaseLabeledVertex a = new BaseLabeledVertex( "a" );
+ final BaseLabeledVertex b = new BaseLabeledVertex( "b" );
+ graph.addVertex( a );
+ graph.addVertex( b );
+
+ // the actual weighted path
+ findShortestPath( graph ).from( a ).to( b ).applyingDijkstra( null );
+
+ fail( "Null Pointer Exception not catched" );
+ }
+
+ @Test( expected = PathNotFoundException.class )
+ public void testNotConnectGraph()
+ {
+ UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> graph =
+ new UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double>();
+
+ final BaseLabeledVertex a = new BaseLabeledVertex( "a" );
+ final BaseLabeledVertex b = new BaseLabeledVertex( "b" );
+ graph.addVertex( a );
+ graph.addVertex( b );
+
+ // the actual weighted path
+ findShortestPath( graph ).from( a ).to( b ).applyingDijkstra( new
DoubleWeight() );
+ }
+
/**
* Test Graph and Dijkstra's solution can be seen on
* <a href="http://en.wikipedia.org/wiki/Dijkstra's_algorithm>Wikipedia</a>
Modified:
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/FloydWarshallTestCase.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/FloydWarshallTestCase.java?rev=1244234&r1=1244233&r2=1244234&view=diff
==============================================================================
---
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/FloydWarshallTestCase.java
(original)
+++
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/shortestpath/FloydWarshallTestCase.java
Tue Feb 14 22:08:26 2012
@@ -26,6 +26,8 @@ import static org.apache.commons.graph.C
import org.apache.commons.graph.MutableGraph;
import org.apache.commons.graph.UndirectedGraph;
+import org.apache.commons.graph.Vertex;
+import org.apache.commons.graph.WeightedEdge;
import org.apache.commons.graph.WeightedGraph;
import org.apache.commons.graph.WeightedPath;
import org.apache.commons.graph.model.BaseLabeledVertex;
@@ -41,6 +43,33 @@ import org.junit.Test;
public class FloydWarshallTestCase
{
+ @Test( expected = NullPointerException.class )
+ public void testNullGraah()
+ {
+ // the actual weighted path
+ findShortestPath( (WeightedGraph<Vertex, WeightedEdge<Double>,
Double>) null ).from( null ).to( null ).applyingDijkstra( new DoubleWeight() );
+ fail( "Null Pointer Exception not catched" );
+ }
+
+ @Test( expected = PathNotFoundException.class )
+ public void testNotConnectGraph()
+ {
+ UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> graph =
+ new UndirectedMutableWeightedGraph<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double>();
+
+ final BaseLabeledVertex a = new BaseLabeledVertex( "a" );
+ final BaseLabeledVertex b = new BaseLabeledVertex( "b" );
+ graph.addVertex( a );
+ graph.addVertex( b );
+
+ // the actual weighted path
+ AllVertexPairsShortestPath<BaseLabeledVertex,
BaseLabeledWeightedEdge<Double>, Double> p =
+ findShortestPath( graph ).applyingFloydWarshall( new
DoubleWeight() );
+
+ p.findShortestPath( a, b );
+ fail( "PathNotFoundException not catched" );
+ }
+
@Test
public void undirectedShortestPath()
{