Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3F1089ECB for ; Tue, 7 Feb 2012 15:43:14 +0000 (UTC) Received: (qmail 2842 invoked by uid 500); 7 Feb 2012 15:43:13 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 2598 invoked by uid 500); 7 Feb 2012 15:43:13 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 2591 invoked by uid 99); 7 Feb 2012 15:43:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Feb 2012 15:43:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Feb 2012 15:43:11 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4FE3A2388A66 for ; Tue, 7 Feb 2012 15:42:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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/ Date: Tue, 07 Feb 2012 15:42:50 -0000 To: commits@commons.apache.org From: simonetripodi@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120207154251.4FE3A2388A66@eris.apache.org> 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 @@ + + Generic Type inference doesn't work in Eclipse + Provide Edmonds-Karp algorithm 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, W, G extends DirectedGraph> FromHeadBuilder findMaxFlow( G graph ) + public static , W, G extends DirectedGraph & WeightedGraph> FromHeadBuilder findMaxFlow( G graph ) { graph = checkNotNull( graph, "Max flow can not be calculated on null graph" ); return new DefaultFromHeadBuilder( graph ); @@ -88,7 +88,7 @@ public final class CommonsGraph, W, G extends Graph> SpanningTreeSourceSelector minimumSpanningTree( G graph ) + public static , W, G extends WeightedGraph> SpanningTreeSourceSelector minimumSpanningTree( G graph ) { graph = checkNotNull( graph, "Minimum spanning tree can not be calculated on null graph" ); return new DefaultSpanningTreeSourceSelector( graph ); @@ -103,7 +103,7 @@ public final class CommonsGraph * @param graph */ - public static , W, G extends Graph> PathSourceSelector findShortesPath( G graph ) + public static , W, G extends WeightedGraph> PathSourceSelector 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 the Graph vertices type. + * @param the Graph weighted edges type. + * @param the weight type + */ +public interface WeightedGraph, W> + extends Graph +{ + +} 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 the WeightedEdge edges type */ public class DirectedMutableWeightedGraph, W> - extends DirectedMutableGraph + extends DirectedMutableGraph implements WeightedGraph { 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 the WeightedEdge edges type */ public class UndirectedMutableWeightedGraph, W> - extends UndirectedMutableGraph + extends UndirectedMutableGraph implements WeightedGraph { 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>) null ).from( a ).to( d ).applyingFordFulkerson( new IntegerWeight() ); + findMaxFlow( (DirectedMutableWeightedGraph, Integer>) null ).from( a ).to( d ).applyingFordFulkerson( new IntegerWeight() ); } @Test(expected=NullPointerException.class) public void testNullGraphAndVertices() { - findMaxFlow( (DirectedGraph>) null ).from( null ).to( null ).applyingFordFulkerson( new IntegerWeight() ); + findMaxFlow( (DirectedMutableWeightedGraph, 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, 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." ); }