You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/06/21 18:15:53 UTC

svn commit: r1138076 - in /commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath: BellmannFord.java FloydWarshall.java

Author: simonetripodi
Date: Tue Jun 21 16:15:53 2011
New Revision: 1138076

URL: http://svn.apache.org/viewvc?rev=1138076&view=rev
Log:
first checkin of Bellman–Ford and Floyd–Warshall algorithms (empty stubs)

Added:
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java   (with props)
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/FloydWarshall.java   (with props)

Added: 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=1138076&view=auto
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java (added)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java Tue Jun 21 16:15:53 2011
@@ -0,0 +1,65 @@
+package org.apache.commons.graph.shortestpath;
+
+import org.apache.commons.graph.Vertex;
+import org.apache.commons.graph.WeightedEdge;
+import org.apache.commons.graph.WeightedGraph;
+import org.apache.commons.graph.WeightedPath;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, 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.
+ */
+
+/**
+ * Contains the BellmanÐFord's shortest path algorithm implementation.
+ */
+public final class BellmannFord
+{
+
+    /**
+     * This class can not be instantiated directly
+     */
+    private BellmannFord()
+    {
+        // do nothing
+    }
+
+    /**
+     * Applies the classical BellmanÐFord's algorithm to find the shortest path from the source to the target, if exists.
+     *
+     * @param <V> the Graph vertices type.
+     * @param <WE> the Graph weighted edges type
+     * @param graph the Graph which shortest path from {@code source} to {@code target} has to be found
+     * @param source the shortest path source Vertex
+     * @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 )
+    {
+        final ShortestDistances<V> shortestDistances = new ShortestDistances<V>();
+        shortestDistances.setWeight( source, 0D );
+
+        final PredecessorsList<V, WE> predecessors = new PredecessorsList<V, WE>();
+
+        
+
+        return null;
+    }
+
+}

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/BellmannFord.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/FloydWarshall.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/FloydWarshall.java?rev=1138076&view=auto
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/FloydWarshall.java (added)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/FloydWarshall.java Tue Jun 21 16:15:53 2011
@@ -0,0 +1,58 @@
+package org.apache.commons.graph.shortestpath;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, 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.Vertex;
+import org.apache.commons.graph.WeightedEdge;
+import org.apache.commons.graph.WeightedGraph;
+import org.apache.commons.graph.WeightedPath;
+
+/**
+ * Contains the FloydÐWarshall's shortest path algorithm implementation.
+ */
+public final class FloydWarshall
+{
+
+    /**
+     * This class can not be instantiated directly
+     */
+    private FloydWarshall()
+    {
+        // do nothing
+    }
+
+    /**
+     * Applies the classical FloydÐWarshall's algorithm to find the shortest path from the source to the target, if exists.
+     *
+     * @param <V> the Graph vertices type.
+     * @param <WE> the Graph weighted edges type
+     * @param graph the Graph which shortest path from {@code source} to {@code target} has to be found
+     * @param source the shortest path source Vertex
+     * @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 )
+    {
+        return null;
+    }
+
+}

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/FloydWarshall.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/FloydWarshall.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/FloydWarshall.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain