Author: simonetripodi
Date: Tue Jun 21 18:49:00 2011
New Revision: 1138133
URL: http://svn.apache.org/viewvc?rev=1138133&view=rev
Log:
as reported on wikipedia (http://en.wikipedia.org/wiki/Bellman-Ford_algorithm)
"The Bellman–Ford algorithm computes single-source shortest paths in a weighted
digraph."
Modified:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java
Modified:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java?rev=1138133&r1=1138132&r2=1138133&view=diff
==============================================================================
---
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java
(original)
+++
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java
Tue Jun 21 18:49:00 2011
@@ -1,5 +1,6 @@
package org.apache.commons.graph.shortestpath;
+import org.apache.commons.graph.DirectedGraph;
import org.apache.commons.graph.Vertex;
import org.apache.commons.graph.WeightedEdge;
import org.apache.commons.graph.WeightedGraph;
@@ -48,9 +49,9 @@ public final class BellmannFord
* @param target the shortest path target Vertex
* @return a path wich describes the shortes path, if any, otherwise a
{@link PathNotFoundException} will be thrown
*/
- public static <V extends Vertex, WE extends WeightedEdge<V>>
WeightedPath<V, WE> findShortestPath( WeightedGraph<V, WE> graph,
-
V source,
-
V target )
+ public static <V extends Vertex, WE extends WeightedEdge<V>, G extends
WeightedGraph<V, WE> & DirectedGraph<V, WE>> WeightedPath<V, WE>
findShortestPath( G graph,
+
V source,
+
V target )
{
final ShortestDistances<V> shortestDistances = new
ShortestDistances<V>();
shortestDistances.setWeight( source, 0D );