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 CF176970D for ; Wed, 7 Mar 2012 21:35:00 +0000 (UTC) Received: (qmail 58182 invoked by uid 500); 7 Mar 2012 21:35:00 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 58118 invoked by uid 500); 7 Mar 2012 21:35:00 -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 58109 invoked by uid 99); 7 Mar 2012 21:35:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Mar 2012 21:35:00 +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; Wed, 07 Mar 2012 21:34:46 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 252BD2388847 for ; Wed, 7 Mar 2012 21:34:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1298136 - in /commons/sandbox/graph/trunk/src: main/java/org/apache/commons/graph/flow/ main/java/org/apache/commons/graph/model/ main/java/org/apache/commons/graph/shortestpath/ main/java/org/apache/commons/graph/spanning/ main/java/org/a... Date: Wed, 07 Mar 2012 21:34:22 -0000 To: commits@commons.apache.org From: cs@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120307213424.252BD2388847@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cs Date: Wed Mar 7 21:34:21 2012 New Revision: 1298136 URL: http://svn.apache.org/viewvc?rev=1298136&view=rev Log: [SANDBOX-404] simplify weight model: merge Zero and Semigroup into Monoid and get rid of OrderedMonoid (replaced by the combination Monoid & Comparator) Removed: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/OrderedMonoid.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/Semigroup.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/Zero.java Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/flow/DefaultMaxFlowAlgorithmSelector.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/flow/FlowNetworkHandler.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/flow/MaxFlowAlgorithmSelector.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryWeightedPath.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/MutableSpanningTree.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultHeuristicBuilder.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultPathSourceSelector.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultShortestPathAlgorithmSelector.java 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/HeuristicBuilder.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/PathSourceSelector.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/ShortestDistances.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathAlgorithmSelector.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/TargetSourceSelector.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/ShortestEdges.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/SpanningTreeAlgorithmSelector.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSourceSelector.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/Monoid.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeightBaseOperations.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeightBaseOperations.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/DoubleWeightBaseOperations.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeightBaseOperations.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/IntegerWeightBaseOperations.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/LongWeightBaseOperations.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/FloydWarshallTestCase.java Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/flow/DefaultMaxFlowAlgorithmSelector.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/flow/DefaultMaxFlowAlgorithmSelector.java?rev=1298136&r1=1298135&r2=1298136&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/flow/DefaultMaxFlowAlgorithmSelector.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/flow/DefaultMaxFlowAlgorithmSelector.java Wed Mar 7 21:34:21 2012 @@ -23,13 +23,15 @@ import static org.apache.commons.graph.C import static org.apache.commons.graph.CommonsGraph.visit; import static org.apache.commons.graph.utils.Assertions.checkNotNull; +import java.util.Comparator; + import org.apache.commons.graph.DirectedGraph; import org.apache.commons.graph.Vertex; import org.apache.commons.graph.VertexPair; import org.apache.commons.graph.WeightedEdge; import org.apache.commons.graph.builder.AbstractGraphConnection; import org.apache.commons.graph.model.BaseLabeledWeightedEdge; -import org.apache.commons.graph.weight.OrderedMonoid; +import org.apache.commons.graph.weight.Monoid; /** * {@link MaxFlowAlgorithmSelector} implementation. @@ -59,7 +61,7 @@ final class DefaultMaxFlowAlgorithmSelec /** * {@inheritDoc} */ - public > W applyingFordFulkerson( WO weightOperations ) + public & Comparator> W applyingFordFulkerson( WO weightOperations ) { final WO checkedWeightOperations = checkNotNull( weightOperations, "Weight operations can not be null to find the max flow in the graph" ); @@ -67,7 +69,7 @@ final class DefaultMaxFlowAlgorithmSelec final DirectedGraph> flowNetwork = newFlowNetwok( graph, checkedWeightOperations ); // create flow network handler - final FlowNetworkHandler flowNetworkHandler = new FlowNetworkHandler( flowNetwork, source, target, checkedWeightOperations ); + final FlowNetworkHandler flowNetworkHandler = new FlowNetworkHandler( flowNetwork, source, target, checkedWeightOperations ); // perform depth first search visit( flowNetwork ).from( source ).applyingDepthFirstSearch( flowNetworkHandler ); @@ -86,7 +88,7 @@ final class DefaultMaxFlowAlgorithmSelec /** * {@inheritDoc} */ - public > W applyingEdmondsKarp( WO weightOperations ) + public & Comparator> W applyingEdmondsKarp( WO weightOperations ) { final WO checkedWeightOperations = checkNotNull( weightOperations, "Weight operations can not be null to find the max flow in the graph" ); @@ -94,7 +96,7 @@ final class DefaultMaxFlowAlgorithmSelec final DirectedGraph> flowNetwork = newFlowNetwok( graph, checkedWeightOperations ); // create flow network handler - final FlowNetworkHandler flowNetworkHandler = new FlowNetworkHandler( flowNetwork, source, target, checkedWeightOperations ); + final FlowNetworkHandler flowNetworkHandler = new FlowNetworkHandler( flowNetwork, source, target, checkedWeightOperations ); // perform breadth first search visit( flowNetwork ).from( source ).applyingBreadthFirstSearch( flowNetworkHandler ); @@ -110,7 +112,7 @@ final class DefaultMaxFlowAlgorithmSelec return flowNetworkHandler.onCompleted(); } - private > DirectedGraph> newFlowNetwok( final G graph, final WO weightOperations ) + private & Comparator> DirectedGraph> newFlowNetwok( final G graph, final WO weightOperations ) { return newDirectedMutableWeightedGraph( new AbstractGraphConnection>() { @@ -134,7 +136,7 @@ final class DefaultMaxFlowAlgorithmSelec if ( graph.getEdge( tail, head ) == null ) { // complete the flow network with a zero-capacity inverse edge - addEdge( new BaseLabeledWeightedEdge( "Inverse edge for " + edge, weightOperations.zero() ) ) + addEdge( new BaseLabeledWeightedEdge( "Inverse edge for " + edge, weightOperations.identity() ) ) .from( tail ).to( head ); } } Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/flow/FlowNetworkHandler.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/flow/FlowNetworkHandler.java?rev=1298136&r1=1298135&r2=1298136&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/flow/FlowNetworkHandler.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/flow/FlowNetworkHandler.java Wed Mar 7 21:34:21 2012 @@ -19,6 +19,7 @@ package org.apache.commons.graph.flow; * under the License. */ +import java.util.Comparator; import java.util.HashMap; import java.util.Map; @@ -29,7 +30,7 @@ import org.apache.commons.graph.Weighted import org.apache.commons.graph.WeightedPath; import org.apache.commons.graph.shortestpath.PredecessorsList; import org.apache.commons.graph.visit.BaseGraphVisitHandler; -import org.apache.commons.graph.weight.OrderedMonoid; +import org.apache.commons.graph.weight.Monoid; /** * Provides standard operations for max-flow algorithms, @@ -38,7 +39,7 @@ import org.apache.commons.graph.weight.O * @param the vertex type * @param the weight type */ -class FlowNetworkHandler +class FlowNetworkHandler & Comparator> extends BaseGraphVisitHandler, DirectedGraph>, W> { @@ -48,7 +49,7 @@ class FlowNetworkHandler weightOperations; + private final WO weightOperations; private W maxFlow; @@ -59,14 +60,14 @@ class FlowNetworkHandler> flowNetwork, V source, V target, OrderedMonoid weightOperations ) + FlowNetworkHandler( DirectedGraph> flowNetwork, V source, V target, WO weightOperations ) { this.flowNetwork = flowNetwork; this.source = source; this.target = target; this.weightOperations = weightOperations; - maxFlow = weightOperations.zero(); + maxFlow = weightOperations.identity(); for ( WeightedEdge edge : flowNetwork.getEdges() ) { @@ -142,7 +143,7 @@ class FlowNetworkHandler, W, G extends DirectedGraph> { @@ -34,7 +36,7 @@ public interface MaxFlowAlgorithmSelecto * @param weightOperations the class responsible for operations on weights * @return */ - > W applyingFordFulkerson( WO weightOperations ); + & Comparator> W applyingFordFulkerson( WO weightOperations ); /** * Calculates the maximum flow using the Edmonds-Karp algorithm. @@ -43,6 +45,6 @@ public interface MaxFlowAlgorithmSelecto * @param weightOperations the class responsible for operations on weights * @return */ - > W applyingEdmondsKarp( WO weightOperations ); + & Comparator> W applyingEdmondsKarp( WO weightOperations ); } Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryWeightedPath.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryWeightedPath.java?rev=1298136&r1=1298135&r2=1298136&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryWeightedPath.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryWeightedPath.java Wed Mar 7 21:34:21 2012 @@ -52,7 +52,7 @@ public final class InMemoryWeightedPath< { super( start, target ); this.weightOperations = weightOperations; - this.weight = weightOperations.zero(); + this.weight = weightOperations.identity(); } /** Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/MutableSpanningTree.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/MutableSpanningTree.java?rev=1298136&r1=1298135&r2=1298136&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/MutableSpanningTree.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/MutableSpanningTree.java Wed Mar 7 21:34:21 2012 @@ -46,7 +46,7 @@ public final class MutableSpanningTree weightOperations) { this.weightOperations = weightOperations; - this.weight = weightOperations.zero(); + this.weight = weightOperations.identity(); } /** Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java?rev=1298136&r1=1298135&r2=1298136&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java Wed Mar 7 21:34:21 2012 @@ -21,6 +21,7 @@ package org.apache.commons.graph.shortes import static org.apache.commons.graph.utils.Assertions.checkNotNull; +import java.util.Comparator; import java.util.HashMap; import java.util.Map; @@ -28,7 +29,7 @@ import org.apache.commons.graph.Vertex; import org.apache.commons.graph.VertexPair; import org.apache.commons.graph.WeightedEdge; import org.apache.commons.graph.WeightedPath; -import org.apache.commons.graph.weight.OrderedMonoid; +import org.apache.commons.graph.weight.Monoid; /** * Represents all shortest paths between all vertex pairs calculated by {@link FloydWarshall} algorithm. @@ -37,19 +38,19 @@ import org.apache.commons.graph.weight.O * @param the Graph weighted edges type * @param the weight type */ -public final class AllVertexPairsShortestPath, W> +public final class AllVertexPairsShortestPath, W, WO extends Monoid & Comparator> { private final Map, WeightedPath> paths = new HashMap, WeightedPath>(); private final Map, W> shortestDistances = new HashMap, W>(); - private final OrderedMonoid weightOperations; + private final WO weightOperations; /** * Constructor visible only inside the package */ - AllVertexPairsShortestPath( OrderedMonoid weightOperations ) + AllVertexPairsShortestPath( WO weightOperations ) { this.weightOperations = weightOperations; } @@ -118,7 +119,7 @@ public final class AllVertexPairsShortes if ( source.equals( target ) ) { - return weightOperations.zero(); + return weightOperations.identity(); } return shortestDistances.get( new VertexPair( source, target ) ); Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultHeuristicBuilder.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultHeuristicBuilder.java?rev=1298136&r1=1298135&r2=1298136&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultHeuristicBuilder.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultHeuristicBuilder.java Wed Mar 7 21:34:21 2012 @@ -21,6 +21,7 @@ package org.apache.commons.graph.shortes import static org.apache.commons.graph.utils.Assertions.checkNotNull; +import java.util.Comparator; import java.util.HashSet; import java.util.Queue; import java.util.Set; @@ -31,9 +32,9 @@ import org.apache.commons.graph.Weighted import org.apache.commons.graph.WeightedGraph; import org.apache.commons.graph.WeightedPath; import org.apache.commons.graph.collections.FibonacciHeap; -import org.apache.commons.graph.weight.OrderedMonoid; +import org.apache.commons.graph.weight.Monoid; -final class DefaultHeuristicBuilder, W, G extends WeightedGraph, WO extends OrderedMonoid> +final class DefaultHeuristicBuilder, W, G extends WeightedGraph, WO extends Monoid & Comparator> implements HeuristicBuilder { @@ -61,11 +62,11 @@ final class DefaultHeuristicBuilder gScores = new ShortestDistances( weightOperations ); - gScores.setWeight( start, weightOperations.zero() ); + final ShortestDistances gScores = new ShortestDistances( weightOperations ); + gScores.setWeight( start, weightOperations.identity() ); // Estimated total cost from start to goal through y. - final ShortestDistances fScores = new ShortestDistances( weightOperations ); + final ShortestDistances fScores = new ShortestDistances( weightOperations ); W hScore = heuristic.applyHeuristic( start, goal ); fScores.setWeight( start, hScore ); Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultPathSourceSelector.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultPathSourceSelector.java?rev=1298136&r1=1298135&r2=1298136&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultPathSourceSelector.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultPathSourceSelector.java Wed Mar 7 21:34:21 2012 @@ -21,6 +21,7 @@ package org.apache.commons.graph.shortes import static org.apache.commons.graph.utils.Assertions.checkNotNull; +import java.util.Comparator; import java.util.HashMap; import java.util.Map; @@ -30,7 +31,7 @@ import org.apache.commons.graph.VertexPa import org.apache.commons.graph.WeightedEdge; import org.apache.commons.graph.WeightedGraph; import org.apache.commons.graph.WeightedPath; -import org.apache.commons.graph.weight.OrderedMonoid; +import org.apache.commons.graph.weight.Monoid; public final class DefaultPathSourceSelector, W, G extends WeightedGraph> implements PathSourceSelector @@ -46,11 +47,11 @@ public final class DefaultPathSourceSele /** * {@inheritDoc} */ - public > AllVertexPairsShortestPath applyingFloydWarshall( WO weightOperations ) + public & Comparator> AllVertexPairsShortestPath applyingFloydWarshall( WO weightOperations ) { weightOperations = checkNotNull( weightOperations, "Floyd-Warshall algorithm can not be applied using null weight operations" ); - AllVertexPairsShortestPath shortestPaths = new AllVertexPairsShortestPath( weightOperations ); + AllVertexPairsShortestPath shortestPaths = new AllVertexPairsShortestPath( weightOperations ); Map, V> next = new HashMap, V>(); // init Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultShortestPathAlgorithmSelector.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultShortestPathAlgorithmSelector.java?rev=1298136&r1=1298135&r2=1298136&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultShortestPathAlgorithmSelector.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/DefaultShortestPathAlgorithmSelector.java Wed Mar 7 21:34:21 2012 @@ -21,6 +21,7 @@ package org.apache.commons.graph.shortes import static org.apache.commons.graph.utils.Assertions.checkNotNull; +import java.util.Comparator; import java.util.HashSet; import java.util.Queue; import java.util.Set; @@ -30,7 +31,7 @@ import org.apache.commons.graph.Weighted import org.apache.commons.graph.WeightedGraph; import org.apache.commons.graph.WeightedPath; import org.apache.commons.graph.collections.FibonacciHeap; -import org.apache.commons.graph.weight.OrderedMonoid; +import org.apache.commons.graph.weight.Monoid; final class DefaultShortestPathAlgorithmSelector, W, G extends WeightedGraph> implements ShortestPathAlgorithmSelector @@ -52,7 +53,7 @@ final class DefaultShortestPathAlgorithm /** * {@inheritDoc} */ - public > HeuristicBuilder applyingAStar( WO weightOperations ) + public & Comparator> HeuristicBuilder applyingAStar( WO weightOperations ) { weightOperations = checkNotNull( weightOperations, "A* algorithm can not be applied using null weight operations" ); return new DefaultHeuristicBuilder( graph, source, target, weightOperations ); @@ -61,12 +62,12 @@ final class DefaultShortestPathAlgorithm /** * {@inheritDoc} */ - public > WeightedPath applyingDijkstra( WO weightOperations ) + public & Comparator> WeightedPath applyingDijkstra( WO weightOperations ) { weightOperations = checkNotNull( weightOperations, "Dijkstra algorithm can not be applied using null weight operations" ); - final ShortestDistances shortestDistances = new ShortestDistances( weightOperations ); - shortestDistances.setWeight( source, weightOperations.zero() ); + final ShortestDistances shortestDistances = new ShortestDistances( weightOperations ); + shortestDistances.setWeight( source, weightOperations.identity() ); final Queue unsettledNodes = new FibonacciHeap( shortestDistances ); unsettledNodes.add( source ); 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=1298136&r1=1298135&r2=1298136&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 Wed Mar 7 21:34:21 2012 @@ -21,12 +21,14 @@ package org.apache.commons.graph.shortes import static org.apache.commons.graph.utils.Assertions.checkNotNull; +import java.util.Comparator; + import org.apache.commons.graph.Vertex; import org.apache.commons.graph.VertexPair; import org.apache.commons.graph.WeightedEdge; import org.apache.commons.graph.WeightedGraph; import org.apache.commons.graph.WeightedPath; -import org.apache.commons.graph.weight.OrderedMonoid; +import org.apache.commons.graph.weight.Monoid; final class DefaultTargetSourceSelector, W, G extends WeightedGraph> implements TargetSourceSelector @@ -45,12 +47,12 @@ final class DefaultTargetSourceSelector< /** * {@inheritDoc} */ - public > AllVertexPairsShortestPath applyingBelmannFord( WO weightOperations ) + public & Comparator> AllVertexPairsShortestPath applyingBelmannFord( WO weightOperations ) { weightOperations = checkNotNull( weightOperations, "Belmann-Ford algorithm can not be applied using null weight operations" ); - final ShortestDistances shortestDistances = new ShortestDistances( weightOperations ); - shortestDistances.setWeight( source, weightOperations.zero() ); + final ShortestDistances shortestDistances = new ShortestDistances( weightOperations ); + shortestDistances.setWeight( source, weightOperations.identity() ); final PredecessorsList predecessors = new PredecessorsList( graph, weightOperations ); @@ -99,7 +101,7 @@ final class DefaultTargetSourceSelector< } } - AllVertexPairsShortestPath allVertexPairsShortestPath = new AllVertexPairsShortestPath( weightOperations ); + AllVertexPairsShortestPath allVertexPairsShortestPath = new AllVertexPairsShortestPath( weightOperations ); for ( V target : graph.getVertices() ) { Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/HeuristicBuilder.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/HeuristicBuilder.java?rev=1298136&r1=1298135&r2=1298136&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/HeuristicBuilder.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/HeuristicBuilder.java Wed Mar 7 21:34:21 2012 @@ -19,11 +19,13 @@ package org.apache.commons.graph.shortes * under the License. */ +import java.util.Comparator; + 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.weight.OrderedMonoid; +import org.apache.commons.graph.weight.Monoid; /** * @@ -32,7 +34,7 @@ import org.apache.commons.graph.weight.O * @param * @param */ -public interface HeuristicBuilder, W, G extends WeightedGraph, WO extends OrderedMonoid> +public interface HeuristicBuilder, W, G extends WeightedGraph, WO extends Comparator & Monoid> { /** Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/PathSourceSelector.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/PathSourceSelector.java?rev=1298136&r1=1298135&r2=1298136&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/PathSourceSelector.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/PathSourceSelector.java Wed Mar 7 21:34:21 2012 @@ -19,10 +19,12 @@ package org.apache.commons.graph.shortes * under the License. */ +import java.util.Comparator; + import org.apache.commons.graph.Vertex; import org.apache.commons.graph.WeightedEdge; import org.apache.commons.graph.WeightedGraph; -import org.apache.commons.graph.weight.OrderedMonoid; +import org.apache.commons.graph.weight.Monoid; /** * @@ -42,7 +44,7 @@ public interface PathSourceSelector> AllVertexPairsShortestPath applyingFloydWarshall( WO weightOperations ); + & Comparator> AllVertexPairsShortestPath applyingFloydWarshall( WO weightOperations ); /** * Specifies the shortest path source. Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/ShortestDistances.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/ShortestDistances.java?rev=1298136&r1=1298135&r2=1298136&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/ShortestDistances.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/ShortestDistances.java Wed Mar 7 21:34:21 2012 @@ -24,7 +24,7 @@ import java.util.HashMap; import java.util.Map; import org.apache.commons.graph.Vertex; -import org.apache.commons.graph.weight.OrderedMonoid; +import org.apache.commons.graph.weight.Monoid; /** * Stores and compares Graph Vertices weights. @@ -32,15 +32,15 @@ import org.apache.commons.graph.weight.O * @param the Graph vertices type * @param the weight type */ -final class ShortestDistances +final class ShortestDistances & Comparator> implements Comparator { private final Map distances = new HashMap(); - private final OrderedMonoid weightOperations; + private final WO weightOperations; - public ShortestDistances( OrderedMonoid weightOperations ) + public ShortestDistances( WO weightOperations ) { this.weightOperations = weightOperations; } Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathAlgorithmSelector.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathAlgorithmSelector.java?rev=1298136&r1=1298135&r2=1298136&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathAlgorithmSelector.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathAlgorithmSelector.java Wed Mar 7 21:34:21 2012 @@ -19,11 +19,13 @@ package org.apache.commons.graph.shortes * under the License. */ +import java.util.Comparator; + 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.weight.OrderedMonoid; +import org.apache.commons.graph.weight.Monoid; /** * @@ -43,7 +45,7 @@ public interface ShortestPathAlgorithmSe * @param weightOperations the class responsible for operations on weights * @return */ - > HeuristicBuilder applyingAStar( WO weightOperations ); + & Comparator> HeuristicBuilder applyingAStar( WO weightOperations ); /** * Calculates the shortest path using Dijkstra's algorithm. @@ -52,6 +54,6 @@ public interface ShortestPathAlgorithmSe * @param weightOperations the class responsible for operations on weights * @return a path which describes the shortest path, if any, otherwise a {@link PathNotFoundException} will be thrown */ - > WeightedPath applyingDijkstra( WO weightOperations ); + & Comparator> WeightedPath applyingDijkstra( WO weightOperations ); } Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/TargetSourceSelector.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/TargetSourceSelector.java?rev=1298136&r1=1298135&r2=1298136&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/TargetSourceSelector.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/TargetSourceSelector.java Wed Mar 7 21:34:21 2012 @@ -19,10 +19,12 @@ package org.apache.commons.graph.shortes * under the License. */ +import java.util.Comparator; + import org.apache.commons.graph.Vertex; import org.apache.commons.graph.WeightedEdge; import org.apache.commons.graph.WeightedGraph; -import org.apache.commons.graph.weight.OrderedMonoid; +import org.apache.commons.graph.weight.Monoid; /** * @@ -42,7 +44,7 @@ public interface TargetSourceSelector> AllVertexPairsShortestPath applyingBelmannFord( WO weightOperations ); + & Comparator> AllVertexPairsShortestPath applyingBelmannFord( WO weightOperations ); /** * Specifies the shortest path source. Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java?rev=1298136&r1=1298135&r2=1298136&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java Wed Mar 7 21:34:21 2012 @@ -23,6 +23,7 @@ import static org.apache.commons.graph.u import static org.apache.commons.graph.utils.Assertions.checkNotNull; +import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -38,7 +39,7 @@ import org.apache.commons.graph.VertexPa import org.apache.commons.graph.WeightedEdge; import org.apache.commons.graph.collections.DisjointSet; import org.apache.commons.graph.model.MutableSpanningTree; -import org.apache.commons.graph.weight.OrderedMonoid; +import org.apache.commons.graph.weight.Monoid; /** * {@link SpanningTreeAlgorithmSelector} implementation. @@ -71,7 +72,7 @@ final class DefaultSpanningTreeAlgorithm } /** {@inheritDoc} */ - public > SpanningTree applyingBoruvkaAlgorithm( WO weightOperations ) + public & Comparator> SpanningTree applyingBoruvkaAlgorithm( WO weightOperations ) { /* *
@@ -170,7 +171,7 @@ final class DefaultSpanningTreeAlgorithm
     /**
      * {@inheritDoc}
      */
-    public > SpanningTree applyingKruskalAlgorithm( WO weightOperations )
+    public  & Comparator> SpanningTree applyingKruskalAlgorithm( WO weightOperations )
     {
         checkNotNull( weightOperations, "The Kruskal algorithm cannot be calculated with null weight operations" );
         final Set settledNodes = new HashSet();
@@ -216,11 +217,11 @@ final class DefaultSpanningTreeAlgorithm
     /**
      * {@inheritDoc}
      */
-    public > SpanningTree applyingPrimAlgorithm( WO weightOperations )
+    public  & Comparator> SpanningTree applyingPrimAlgorithm( WO weightOperations )
     {
         checkNotNull( weightOperations, "The Prim algorithm cannot be calculated with null weight operations" );
 
-        final ShortestEdges shortestEdges = new ShortestEdges( graph, source, weightOperations );
+        final ShortestEdges shortestEdges = new ShortestEdges( graph, source, weightOperations );
 
         final PriorityQueue unsettledNodes = new PriorityQueue( graph.getOrder(), shortestEdges );
         unsettledNodes.add( source );

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java?rev=1298136&r1=1298135&r2=1298136&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java Wed Mar  7 21:34:21 2012
@@ -26,6 +26,7 @@ import static org.apache.commons.graph.u
 import static org.apache.commons.graph.utils.Assertions.checkState;
 
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 
@@ -37,7 +38,7 @@ import org.apache.commons.graph.Weighted
 import org.apache.commons.graph.WeightedGraph;
 import org.apache.commons.graph.model.MutableSpanningTree;
 import org.apache.commons.graph.shortestpath.PathNotFoundException;
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.weight.Monoid;
 
 /**
  * {@link SpanningTreeSourceSelector} implementation.
@@ -80,7 +81,7 @@ public final class DefaultSpanningTreeSo
     /**
      * {@inheritDoc}
      */
-    public > SpanningTree applyingReverseDeleteAlgorithm( WO weightOperations )
+    public  & Comparator> SpanningTree applyingReverseDeleteAlgorithm( WO weightOperations )
     {
 
         checkNotNull( weightOperations, "The Reverse-Delete algorithm cannot be calulated with null weight operations" );

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/ShortestEdges.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/ShortestEdges.java?rev=1298136&r1=1298135&r2=1298136&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/ShortestEdges.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/ShortestEdges.java Wed Mar  7 21:34:21 2012
@@ -31,7 +31,7 @@ import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.VertexPair;
 import org.apache.commons.graph.WeightedEdge;
 import org.apache.commons.graph.model.MutableSpanningTree;
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.weight.Monoid;
 
 /**
  * The predecessor list is a list of {@link Vertex} of a {@link org.apache.commons.graph.Graph}.
@@ -41,19 +41,19 @@ import org.apache.commons.graph.weight.O
  * @param  the Graph edges type
  * @param  the weight type
  */
-final class ShortestEdges, W>
+final class ShortestEdges, W, WO extends Monoid & Comparator>
     implements Comparator
 {
 
     private final Map predecessors = new HashMap();
 
-    private final OrderedMonoid weightOperations;
+    private final WO weightOperations;
     
     private final Graph graph;
 
     private final V source;
 
-    public ShortestEdges(Graph graph, V source, OrderedMonoid weightOperations )
+    public ShortestEdges(Graph graph, V source, WO weightOperations )
     {
         this.graph = graph;
         this.source = source;
@@ -132,7 +132,7 @@ final class ShortestEdges> SpanningTree applyingBoruvkaAlgorithm( WO weightOperations );
+     & Comparator> SpanningTree applyingBoruvkaAlgorithm( WO weightOperations );
 
     /**
      * Applies the Kruskal's algorithm.
@@ -52,7 +54,7 @@ public interface SpanningTreeAlgorithmSe
      * @param weightOperations the class responsible for operations on weights
      * @return the calculated spanning tree
      */
-    > SpanningTree applyingKruskalAlgorithm( WO weightOperations );
+     & Comparator> SpanningTree applyingKruskalAlgorithm( WO weightOperations );
 
     /**
      * Applies the Prim's algorithm.
@@ -61,6 +63,6 @@ public interface SpanningTreeAlgorithmSe
      * @param weightOperations the class responsible for operations on weights
      * @return the calculated spanning tree
      */
-    > SpanningTree applyingPrimAlgorithm( WO weightOperations );
+     & Comparator> SpanningTree applyingPrimAlgorithm( WO weightOperations );
 
 }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSourceSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSourceSelector.java?rev=1298136&r1=1298135&r2=1298136&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSourceSelector.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSourceSelector.java Wed Mar  7 21:34:21 2012
@@ -19,11 +19,13 @@ package org.apache.commons.graph.spannin
  * under the License.
  */
 
+import java.util.Comparator;
+
 import org.apache.commons.graph.Graph;
 import org.apache.commons.graph.SpanningTree;
 import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.WeightedEdge;
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.weight.Monoid;
 
 /**
  * Spanning Tree source selector.
@@ -71,6 +73,6 @@ public interface SpanningTreeSourceSelec
      * @param weightOperations the weight operations
      * @return the calculated spanning tree
      */
-    > SpanningTree applyingReverseDeleteAlgorithm( WO weightOperations );
+     & Comparator> SpanningTree applyingReverseDeleteAlgorithm( WO weightOperations );
 
 }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/Monoid.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/Monoid.java?rev=1298136&r1=1298135&r2=1298136&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/Monoid.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/Monoid.java Wed Mar  7 21:34:21 2012
@@ -22,17 +22,34 @@ package org.apache.commons.graph.weight;
 /**
  * A {@link Monoid} is a {@link Semigroup} with an identity value.
  *
- * @param  the type of the elements in the {@link Monoid}
+ * @param  the type of the elements in the {@link Monoid}
  */
-public interface Monoid
-    extends Zero, Semigroup
+public interface Monoid
 {
 
     /**
+     * Returns the identity value.
+     *
+     * @return the identity value
+     */
+    E identity();
+
+    /**
+     * Returns the result of the associative binary operation defined by this
+     * monoid between two elements of appropriate type.
+     *
+     * @param s1 the first element
+     * @param element2 the second element
+     * @return the result of the associative binary operation
+     */
+    E append( E element1, E element2 );
+
+    /**
      * Returns the inverse of the input element.
+     *
      * @param element the input element
      * @return the inverse of the input element
      */
-    M inverse( M element );
+    E inverse( E element );
 
 }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeightBaseOperations.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeightBaseOperations.java?rev=1298136&r1=1298135&r2=1298136&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeightBaseOperations.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeightBaseOperations.java Wed Mar  7 21:34:21 2012
@@ -22,21 +22,22 @@ package org.apache.commons.graph.weight.
 import static java.math.BigDecimal.ZERO;
 
 import java.math.BigDecimal;
+import java.util.Comparator;
 
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.weight.Monoid;
 
 /**
  * The class {@link BigDecimalWeightBaseOperations} provides operations and properties
  * for weights of type {@link BigDecimal}.
  */
 public class BigDecimalWeightBaseOperations
-    implements OrderedMonoid
+    implements Monoid, Comparator
 {
 
     /**
      * {@inheritDoc}
      */
-    public BigDecimal zero()
+    public BigDecimal identity()
     {
         return ZERO;
     }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeightBaseOperations.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeightBaseOperations.java?rev=1298136&r1=1298135&r2=1298136&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeightBaseOperations.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeightBaseOperations.java Wed Mar  7 21:34:21 2012
@@ -22,21 +22,22 @@ package org.apache.commons.graph.weight.
 import static java.math.BigInteger.ZERO;
 
 import java.math.BigInteger;
+import java.util.Comparator;
 
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.weight.Monoid;
 
 /**
  * The class {@link BigIntegerWeightBaseOperations} provides operations and properties
  * for weights of type {@link BigInteger}.
  */
 public class BigIntegerWeightBaseOperations
-    implements OrderedMonoid
+    implements Monoid, Comparator
 {
 
     /**
      * {@inheritDoc}
      */
-    public BigInteger zero()
+    public BigInteger identity()
     {
         return ZERO;
     }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/DoubleWeightBaseOperations.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/DoubleWeightBaseOperations.java?rev=1298136&r1=1298135&r2=1298136&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/DoubleWeightBaseOperations.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/DoubleWeightBaseOperations.java Wed Mar  7 21:34:21 2012
@@ -19,20 +19,22 @@ package org.apache.commons.graph.weight.
  * under the License.
  */
 
-import org.apache.commons.graph.weight.OrderedMonoid;
+import java.util.Comparator;
+
+import org.apache.commons.graph.weight.Monoid;
 
 /**
  * The class {@link DoubleWeightBaseOperations} provides operations and properties
  * for weights of type {@link Double}.
  */
 public class DoubleWeightBaseOperations
-    implements OrderedMonoid
+    implements Monoid, Comparator
 {
 
     /**
      * {@inheritDoc}
      */
-    public Double zero()
+    public Double identity()
     {
         return 0.0;
     }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeightBaseOperations.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeightBaseOperations.java?rev=1298136&r1=1298135&r2=1298136&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeightBaseOperations.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeightBaseOperations.java Wed Mar  7 21:34:21 2012
@@ -19,20 +19,22 @@ package org.apache.commons.graph.weight.
  * under the License.
  */
 
-import org.apache.commons.graph.weight.OrderedMonoid;
+import java.util.Comparator;
+
+import org.apache.commons.graph.weight.Monoid;
 
 /**
  * The class {@link FloatWeightBaseOperations} provides operations and properties
  * for weights of type {@link Float}.
  */
 public class FloatWeightBaseOperations
-    implements OrderedMonoid
+    implements Monoid, Comparator
 {
 
     /**
      * {@inheritDoc}
      */
-    public Float zero()
+    public Float identity()
     {
         return 0.0F;
     }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/IntegerWeightBaseOperations.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/IntegerWeightBaseOperations.java?rev=1298136&r1=1298135&r2=1298136&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/IntegerWeightBaseOperations.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/IntegerWeightBaseOperations.java Wed Mar  7 21:34:21 2012
@@ -19,20 +19,22 @@ package org.apache.commons.graph.weight.
  * under the License.
  */
 
-import org.apache.commons.graph.weight.OrderedMonoid;
+import java.util.Comparator;
+
+import org.apache.commons.graph.weight.Monoid;
 
 /**
  * The class {@link IntegerWeightBaseOperations} provides operations and properties
  * for weights of type {@link Integer}.
  */
 public class IntegerWeightBaseOperations
-    implements OrderedMonoid
+    implements Monoid, Comparator
 {
 
     /**
      * {@inheritDoc}
      */
-    public Integer zero()
+    public Integer identity()
     {
         return 0;
     }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/LongWeightBaseOperations.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/LongWeightBaseOperations.java?rev=1298136&r1=1298135&r2=1298136&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/LongWeightBaseOperations.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/weight/primitive/LongWeightBaseOperations.java Wed Mar  7 21:34:21 2012
@@ -19,20 +19,22 @@ package org.apache.commons.graph.weight.
  * under the License.
  */
 
-import org.apache.commons.graph.weight.OrderedMonoid;
+import java.util.Comparator;
+
+import org.apache.commons.graph.weight.Monoid;
 
 /**
  * The class {@link LongWeightBaseOperations} provides operations and properties
  * for weights of type {@link Long}.
  */
 public class LongWeightBaseOperations
-    implements OrderedMonoid
+    implements Monoid, Comparator
 {
 
     /**
      * {@inheritDoc}
      */
-    public Long zero()
+    public Long identity()
     {
         return 0L;
     }

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=1298136&r1=1298135&r2=1298136&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 Wed Mar  7 21:34:21 2012
@@ -83,7 +83,7 @@ public final class BellmannFordTestCase
         BaseLabeledVertex a = null;
         BaseLabeledVertex b = null;
         // the actual weighted path
-        AllVertexPairsShortestPath, Double> allVertexPairsShortestPath =
+        AllVertexPairsShortestPath, Double, DoubleWeightBaseOperations> allVertexPairsShortestPath =
             null;
         try
         {
@@ -149,7 +149,7 @@ public final class BellmannFordTestCase
         expected.addConnectionInTail( four, new BaseLabeledWeightedEdge( "4 -> 3", -3D ), three );
 
         // the actual weighted path
-        AllVertexPairsShortestPath, Double> allVertexPairsShortestPath =
+        AllVertexPairsShortestPath, Double, DoubleWeightBaseOperations> allVertexPairsShortestPath =
             findShortestPath( graph ).from( one ).applyingBelmannFord( new DoubleWeightBaseOperations() );
 
         WeightedPath, Double> actual =

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=1298136&r1=1298135&r2=1298136&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 Wed Mar  7 21:34:21 2012
@@ -62,7 +62,7 @@ public class FloydWarshallTestCase
         graph.addVertex( b );
 
         // the actual weighted path
-        AllVertexPairsShortestPath, Double> p =
+        AllVertexPairsShortestPath, Double, DoubleWeightBaseOperations> p =
             findShortestPath( graph ).applyingFloydWarshall( new DoubleWeightBaseOperations() );
 
         p.findShortestPath( a, b );
@@ -115,7 +115,7 @@ public class FloydWarshallTestCase
         mutable.addEdge( four, new BaseLabeledWeightedEdge( "4 -> 5", 6D ), five );
         mutable.addEdge( six, new BaseLabeledWeightedEdge( "6 -> 5", 9D ), five );
 
-        AllVertexPairsShortestPath, Double> p =
+        AllVertexPairsShortestPath, Double, DoubleWeightBaseOperations> p =
             findShortestPath( weighted ).applyingFloydWarshall( new DoubleWeightBaseOperations() );
 
         if ( weighted instanceof UndirectedGraph )