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 2012/02/07 16:42:50 UTC

svn commit: r1241491 - in /commons/sandbox/graph/trunk/src: changes/ main/java/org/apache/commons/graph/ main/java/org/apache/commons/graph/model/ test/java/org/apache/commons/graph/flow/ test/java/org/apache/commons/graph/spanning/

Author: simonetripodi
Date: Tue Feb  7 15:42:50 2012
New Revision: 1241491

URL: http://svn.apache.org/viewvc?rev=1241491&view=rev
Log:
[SANDBOX-388] Generic Type inference doesn't work in Eclipse - patch provided by Steven Dolg & Claudio Squarcella

Added:
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/WeightedGraph.java   (with props)
Modified:
    commons/sandbox/graph/trunk/src/changes/changes.xml
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/CommonsGraph.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableWeightedGraph.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableWeightedGraph.java
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/flow/FordFulkersonTestCase.java
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java

Modified: commons/sandbox/graph/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/changes/changes.xml?rev=1241491&r1=1241490&r2=1241491&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/changes/changes.xml (original)
+++ commons/sandbox/graph/trunk/src/changes/changes.xml Tue Feb  7 15:42:50 2012
@@ -23,6 +23,9 @@
   </properties>
   <body>
   <release version="0.1" date="201?-??-??" description="First release.">
+    <action dev="simonetripodi" type="update" issue="SANDBOX-388" due-to="Steven Dolg, Claudio Squarcella">
+      Generic Type inference doesn't work in Eclipse
+    </action>
     <action dev="simonetripodi" type="update" issue="SANDBOX-385" due-to="Claudio Squarcella">
       Provide Edmonds-Karp algorithm
     </action>

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/CommonsGraph.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/CommonsGraph.java?rev=1241491&r1=1241490&r2=1241491&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/CommonsGraph.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/CommonsGraph.java Tue Feb  7 15:42:50 2012
@@ -77,7 +77,7 @@ public final class CommonsGraph<V extend
      * @param graph the input edge-weighted graph
      * @return
      */
-    public static <V extends Vertex, WE extends WeightedEdge<W>, W, G extends DirectedGraph<V, WE>> FromHeadBuilder<V, WE, W, G> findMaxFlow( G graph )
+    public static <V extends Vertex, WE extends WeightedEdge<W>, W, G extends DirectedGraph<V, WE> & WeightedGraph<V, WE, W>> FromHeadBuilder<V, WE, W, G> findMaxFlow( G graph )
     {
         graph = checkNotNull( graph, "Max flow can not be calculated on null graph" );
         return new DefaultFromHeadBuilder<V, WE, W, G>( graph );
@@ -88,7 +88,7 @@ public final class CommonsGraph<V extend
      * @param graph
      * @return
      */
-    public static <V extends Vertex, WE extends WeightedEdge<W>, W, G extends Graph<V, WE>> SpanningTreeSourceSelector<V, W, WE, G> minimumSpanningTree( G graph )
+    public static <V extends Vertex, WE extends WeightedEdge<W>, W, G extends WeightedGraph<V, WE, W>> SpanningTreeSourceSelector<V, W, WE, G> minimumSpanningTree( G graph )
     {
         graph = checkNotNull( graph, "Minimum spanning tree can not be calculated on null graph" );
         return new DefaultSpanningTreeSourceSelector<V, W, WE, G>( graph );
@@ -103,7 +103,7 @@ public final class CommonsGraph<V extend
      * @param <G>
      * @param graph
      */
-    public static <V extends Vertex, WE extends WeightedEdge<W>, W, G extends Graph<V, WE>> PathSourceSelector<V, W, WE, G> findShortesPath( G graph )
+    public static <V extends Vertex, WE extends WeightedEdge<W>, W, G extends WeightedGraph<V, WE, W>> PathSourceSelector<V, W, WE, G> findShortestPath( G graph )
     {
         graph = checkNotNull( graph, "Minimum spanning tree can not be calculated on null graph" );
         return null;

Added: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/WeightedGraph.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/WeightedGraph.java?rev=1241491&view=auto
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/WeightedGraph.java (added)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/WeightedGraph.java Tue Feb  7 15:42:50 2012
@@ -0,0 +1,33 @@
+package org.apache.commons.graph;
+
+/*
+ * 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.
+ */
+
+/**
+ * A weighted graph associates a label (weight) with every edge in the graph.
+ *
+ * @param <V> the Graph vertices type.
+ * @param <WE> the Graph weighted edges type.
+ * @param <W> the weight type
+ */
+public interface WeightedGraph<V extends Vertex, WE extends WeightedEdge<W>, W>
+    extends Graph<V, WE>
+{
+
+}

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

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

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

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableWeightedGraph.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableWeightedGraph.java?rev=1241491&r1=1241490&r2=1241491&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableWeightedGraph.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableWeightedGraph.java Tue Feb  7 15:42:50 2012
@@ -21,6 +21,7 @@ package org.apache.commons.graph.model;
 
 import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.WeightedEdge;
+import org.apache.commons.graph.WeightedGraph;
 
 /**
  * A memory-based implementation of a mutable, directed weighted Graph.
@@ -29,7 +30,7 @@ import org.apache.commons.graph.Weighted
  * @param <WE> the WeightedEdge edges type
  */
 public class DirectedMutableWeightedGraph<V extends Vertex, WE extends WeightedEdge<W>, W>
-    extends DirectedMutableGraph<V, WE>
+    extends DirectedMutableGraph<V, WE> implements WeightedGraph<V, WE, W>
 {
 
     private static final long serialVersionUID = 3749802534265570596L;

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableWeightedGraph.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableWeightedGraph.java?rev=1241491&r1=1241490&r2=1241491&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableWeightedGraph.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableWeightedGraph.java Tue Feb  7 15:42:50 2012
@@ -21,6 +21,7 @@ package org.apache.commons.graph.model;
 
 import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.WeightedEdge;
+import org.apache.commons.graph.WeightedGraph;
 
 /**
  * A memory-based implementation of a mutable, undirected weighted Graph.
@@ -29,7 +30,7 @@ import org.apache.commons.graph.Weighted
  * @param <WE> the WeightedEdge edges type
  */
 public class UndirectedMutableWeightedGraph<V extends Vertex, WE extends WeightedEdge<W>, W>
-    extends UndirectedMutableGraph<V, WE>
+    extends UndirectedMutableGraph<V, WE> implements WeightedGraph<V, WE, W>
 {
 
     private static final long serialVersionUID = -4846482321351740099L;

Modified: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/flow/FordFulkersonTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/flow/FordFulkersonTestCase.java?rev=1241491&r1=1241490&r2=1241491&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/flow/FordFulkersonTestCase.java (original)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/flow/FordFulkersonTestCase.java Tue Feb  7 15:42:50 2012
@@ -23,7 +23,6 @@ import static org.apache.commons.graph.C
 import static org.apache.commons.graph.CommonsGraph.newDirectedMutableWeightedGraph;
 import static org.junit.Assert.assertEquals;
 
-import org.apache.commons.graph.DirectedGraph;
 import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.WeightedEdge;
 import org.apache.commons.graph.builder.AbstractGraphConnection;
@@ -40,19 +39,20 @@ import org.junit.Test;
  */
 public final class FordFulkersonTestCase
 {
+
     @Test(expected=NullPointerException.class)
     public void testNullGraph()
     {
         final BaseLabeledVertex a = new BaseLabeledVertex( "A" );
         final BaseLabeledVertex d = new BaseLabeledVertex( "D" );
 
-        findMaxFlow( (DirectedGraph<Vertex, WeightedEdge<Integer>>) null ).from( a ).to( d ).applyingFordFulkerson( new IntegerWeight() );
+        findMaxFlow( (DirectedMutableWeightedGraph<Vertex, WeightedEdge<Integer>, Integer>) null ).from( a ).to( d ).applyingFordFulkerson( new IntegerWeight() );
     }
 
     @Test(expected=NullPointerException.class)
     public void testNullGraphAndVertices()
     {
-        findMaxFlow( (DirectedGraph<Vertex, WeightedEdge<Integer>>) null ).from( null ).to( null ).applyingFordFulkerson( new IntegerWeight() );
+        findMaxFlow( (DirectedMutableWeightedGraph<Vertex, WeightedEdge<Integer>, Integer>) null ).from( null ).to( null ).applyingFordFulkerson( new IntegerWeight() );
     }
 
     @Test

Modified: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java?rev=1241491&r1=1241490&r2=1241491&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java (original)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java Tue Feb  7 15:42:50 2012
@@ -117,8 +117,7 @@ public final class BoruvkaTestCase
         input.addVertex( new BaseLabeledVertex( "F" ) );
         input.addVertex( new BaseLabeledVertex( "G" ) );
 
-        SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> actual =
-            minimumSpanningTree( input ).fromArbitrarySource().applyingBoruvkaAlgorithm( new DoubleWeight() );
+        minimumSpanningTree( input ).fromArbitrarySource().applyingBoruvkaAlgorithm( new DoubleWeight() );
 
         fail( "Exception not thrown!. Boruvka's algorithm cannot be calculated on a not-connected graph." );
     }