Author: simonetripodi
Date: Sat Mar 10 00:48:56 2012
New Revision: 1299124
URL: http://svn.apache.org/viewvc?rev=1299124&view=rev
Log:
merged simplified version of [SANDBOX-404]
Removed:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/Semigroup.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/Zero.java
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/flow/DefaultMaxFlowAlgorithmSelector.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/flow/FlowNetworkHandler.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/model/InMemoryWeightedPath.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/model/MutableSpanningTree.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/DefaultHeuristicBuilder.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/DefaultShortestPathAlgorithmSelector.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/DefaultTargetSourceSelector.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/spanning/ShortestEdges.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/Monoid.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeightBaseOperations.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeightBaseOperations.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/DoubleWeightBaseOperations.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeightBaseOperations.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/IntegerWeightBaseOperations.java
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/LongWeightBaseOperations.java
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/flow/DefaultMaxFlowAlgorithmSelector.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/flow/DefaultMaxFlowAlgorithmSelector.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/flow/DefaultMaxFlowAlgorithmSelector.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/flow/DefaultMaxFlowAlgorithmSelector.java
Sat Mar 10 00:48:56 2012
@@ -184,7 +184,7 @@ final class DefaultMaxFlowAlgorithmSelec
{
if ( input.getWrapped() == null )
{
- return weightOperations.zero();
+ return weightOperations.identity();
}
return weightedEdges.map( input.getWrapped() );
}
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/flow/FlowNetworkHandler.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/flow/FlowNetworkHandler.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/flow/FlowNetworkHandler.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/flow/FlowNetworkHandler.java
Sat Mar 10 00:48:56 2012
@@ -68,7 +68,7 @@ class FlowNetworkHandler<V, E, W>
this.weightOperations = weightOperations;
this.weightedEdges = weightedEdges;
- maxFlow = weightOperations.zero();
+ maxFlow = weightOperations.identity();
for ( E edge : flowNetwork.getEdges() )
{
@@ -144,7 +144,7 @@ class FlowNetworkHandler<V, E, W>
{
W residualEdgeCapacity = residualEdgeCapacities.get( edge );
// avoid expanding the edge when it has no residual capacity
- if ( weightOperations.compare( residualEdgeCapacity,
weightOperations.zero() ) <= 0 )
+ if ( weightOperations.compare( residualEdgeCapacity,
weightOperations.identity() ) <= 0 )
{
return false;
}
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/model/InMemoryWeightedPath.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/model/InMemoryWeightedPath.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/model/InMemoryWeightedPath.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/model/InMemoryWeightedPath.java
Sat Mar 10 00:48:56 2012
@@ -55,7 +55,7 @@ public final class InMemoryWeightedPath<
this.weightOperations = weightOperations;
this.weightedEdges = weightedEdges;
- this.weight = weightOperations.zero();
+ this.weight = weightOperations.identity();
}
/**
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/model/MutableSpanningTree.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/model/MutableSpanningTree.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/model/MutableSpanningTree.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/model/MutableSpanningTree.java
Sat Mar 10 00:48:56 2012
@@ -50,7 +50,7 @@ public final class MutableSpanningTree<V
this.weightOperations = weightOperations;
this.weightedEdges = weightedEdges;
- this.weight = weightOperations.zero();
+ this.weight = weightOperations.identity();
}
/**
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java
Sat Mar 10 00:48:56 2012
@@ -116,7 +116,7 @@ public final class AllVertexPairsShortes
if ( source.equals( target ) )
{
- return weightOperations.zero();
+ return weightOperations.identity();
}
return shortestDistances.get( new VertexPair<V>( source, target ) );
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/DefaultHeuristicBuilder.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/DefaultHeuristicBuilder.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/DefaultHeuristicBuilder.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/DefaultHeuristicBuilder.java
Sat Mar 10 00:48:56 2012
@@ -64,7 +64,7 @@ final class DefaultHeuristicBuilder<V, W
// Cost from start along best known path.
final ShortestDistances<V, W> gScores = new ShortestDistances<V, W>(
weightOperations );
- gScores.setWeight( start, weightOperations.zero() );
+ gScores.setWeight( start, weightOperations.identity() );
// Estimated total cost from start to goal through y.
final ShortestDistances<V, W> fScores = new ShortestDistances<V, W>(
weightOperations );
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/DefaultShortestPathAlgorithmSelector.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/DefaultShortestPathAlgorithmSelector.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/DefaultShortestPathAlgorithmSelector.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/DefaultShortestPathAlgorithmSelector.java
Sat Mar 10 00:48:56 2012
@@ -68,7 +68,7 @@ final class DefaultShortestPathAlgorithm
weightOperations = checkNotNull( weightOperations, "Dijkstra algorithm
can not be applied using null weight operations" );
final ShortestDistances<V, W> shortestDistances = new
ShortestDistances<V, W>( weightOperations );
- shortestDistances.setWeight( source, weightOperations.zero() );
+ shortestDistances.setWeight( source, weightOperations.identity() );
final Queue<V> unsettledNodes = new FibonacciHeap<V>(
shortestDistances );
unsettledNodes.add( source );
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/DefaultTargetSourceSelector.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/DefaultTargetSourceSelector.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/DefaultTargetSourceSelector.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/shortestpath/DefaultTargetSourceSelector.java
Sat Mar 10 00:48:56 2012
@@ -52,7 +52,7 @@ final class DefaultTargetSourceSelector<
weightOperations = checkNotNull( weightOperations, "Belmann-Ford
algorithm can not be applied using null weight operations" );
final ShortestDistances<V, W> shortestDistances = new
ShortestDistances<V, W>( weightOperations );
- shortestDistances.setWeight( source, weightOperations.zero() );
+ shortestDistances.setWeight( source, weightOperations.identity() );
final PredecessorsList<V, WE, W> predecessors = new
PredecessorsList<V, WE, W>( graph, weightOperations, weightedEdges );
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/spanning/ShortestEdges.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/spanning/ShortestEdges.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/spanning/ShortestEdges.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/spanning/ShortestEdges.java
Sat Mar 10 00:48:56 2012
@@ -132,7 +132,7 @@ final class ShortestEdges<V, WE, W>
{
if ( source.equals( vertex ) )
{
- return weightOperations.zero();
+ return weightOperations.identity();
}
WE edge = predecessors.get( vertex );
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/Monoid.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/Monoid.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/Monoid.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/Monoid.java
Sat Mar 10 00:48:56 2012
@@ -22,17 +22,33 @@ package org.apache.commons.graph.weight;
/**
* A {@link Monoid} is a {@link Semigroup} with an identity value.
*
- * @param <M> the type of the elements in the {@link Monoid}
+ * @param <E> the type of the elements in the {@link Monoid}
*/
-public interface Monoid<M>
- extends Zero<M>, Semigroup<M>
+public interface Monoid<E>
{
/**
+ * Returns the identity value.
+ *
+ * @return the identity value
+ */
+ E identity();
+
+ /**
+ * Returns the result of the associative binary operation defined by this
+ * {@link Semigroup} between two elements of appropriate type.
+ *
+ * @param e1 the first element
+ * @param e2 the second element
+ * @return the result of the associative binary operation
+ */
+ E append( E e1, E e2 );
+
+ /**
* 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/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeightBaseOperations.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeightBaseOperations.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeightBaseOperations.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/BigDecimalWeightBaseOperations.java
Sat Mar 10 00:48:56 2012
@@ -36,7 +36,7 @@ public class BigDecimalWeightBaseOperati
/**
* {@inheritDoc}
*/
- public BigDecimal zero()
+ public BigDecimal identity()
{
return ZERO;
}
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeightBaseOperations.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeightBaseOperations.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeightBaseOperations.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/BigIntegerWeightBaseOperations.java
Sat Mar 10 00:48:56 2012
@@ -36,7 +36,7 @@ public class BigIntegerWeightBaseOperati
/**
* {@inheritDoc}
*/
- public BigInteger zero()
+ public BigInteger identity()
{
return ZERO;
}
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/DoubleWeightBaseOperations.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/DoubleWeightBaseOperations.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/DoubleWeightBaseOperations.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/DoubleWeightBaseOperations.java
Sat Mar 10 00:48:56 2012
@@ -32,7 +32,7 @@ public class DoubleWeightBaseOperations
/**
* {@inheritDoc}
*/
- public Double zero()
+ public Double identity()
{
return 0.0;
}
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeightBaseOperations.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeightBaseOperations.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeightBaseOperations.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/FloatWeightBaseOperations.java
Sat Mar 10 00:48:56 2012
@@ -32,7 +32,7 @@ public class FloatWeightBaseOperations
/**
* {@inheritDoc}
*/
- public Float zero()
+ public Float identity()
{
return 0.0F;
}
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/IntegerWeightBaseOperations.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/IntegerWeightBaseOperations.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/IntegerWeightBaseOperations.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/IntegerWeightBaseOperations.java
Sat Mar 10 00:48:56 2012
@@ -32,7 +32,7 @@ public class IntegerWeightBaseOperations
/**
* {@inheritDoc}
*/
- public Integer zero()
+ public Integer identity()
{
return 0;
}
Modified:
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/LongWeightBaseOperations.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/LongWeightBaseOperations.java?rev=1299124&r1=1299123&r2=1299124&view=diff
==============================================================================
---
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/LongWeightBaseOperations.java
(original)
+++
commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/weight/primitive/LongWeightBaseOperations.java
Sat Mar 10 00:48:56 2012
@@ -32,7 +32,7 @@ public class LongWeightBaseOperations
/**
* {@inheritDoc}
*/
- public Long zero()
+ public Long identity()
{
return 0L;
}