commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1298196 - in /commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph: model/ spanning/
Date Wed, 07 Mar 2012 23:08:13 GMT
Author: simonetripodi
Date: Wed Mar  7 23:08:13 2012
New Revision: 1298196

URL: http://svn.apache.org/viewvc?rev=1298196&view=rev
Log:
plugged the edge mapper inside the weighted spanning tree

Modified:
    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/spanning/DefaultSpanningTreeAlgorithmSelector.java
    commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java
    commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/spanning/ShortestEdges.java

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=1298196&r1=1298195&r2=1298196&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
Wed Mar  7 23:08:13 2012
@@ -19,6 +19,7 @@ package org.apache.commons.graph.model;
  * under the License.
  */
 
+import org.apache.commons.graph.Mapper;
 import org.apache.commons.graph.SpanningTree;
 import org.apache.commons.graph.weight.Monoid;
 
@@ -38,12 +39,17 @@ public final class MutableSpanningTree<V
 
     private static final long serialVersionUID = -4371938772248573879L;
 
-    private Monoid<W> weightOperations;
+    private final Monoid<W> weightOperations;
+
+    private final Mapper<WE, W> weightedEdges;
 
     private W weight;
 
-    public MutableSpanningTree(Monoid<W> weightOperations) {
+    public MutableSpanningTree( Monoid<W> weightOperations, Mapper<WE, W> weightedEdges
)
+    {
         this.weightOperations = weightOperations;
+        this.weightedEdges = weightedEdges;
+
         this.weight = weightOperations.zero();
     }
 
@@ -62,7 +68,7 @@ public final class MutableSpanningTree<V
     protected void decorateAddEdge( V head, WE e, V tail )
     {
         super.decorateAddEdge( head, e, tail );
-        // TODO weight = weightOperations.append( weight, e.getWeight() );
+        weight = weightOperations.append( weight, weightedEdges.map( e ) );
     }
 
     /**
@@ -71,7 +77,7 @@ public final class MutableSpanningTree<V
     @Override
     protected void decorateRemoveEdge( WE e )
     {
-        // TODO weight = weightOperations.append( weight, weightOperations.inverse( e.getWeight()
) );
+        weight = weightOperations.append( weight, weightOperations.inverse( weightedEdges.map(
e ) ) );
     }
 
 }

Modified: commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java?rev=1298196&r1=1298195&r2=1298196&view=diff
==============================================================================
--- commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java
(original)
+++ commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java
Wed Mar  7 23:08:13 2012
@@ -91,7 +91,7 @@ final class DefaultSpanningTreeAlgorithm
 
         checkNotNull( weightOperations, "The Boruvka algorithm cannot be calculated with
null weight operations" );
 
-        final MutableSpanningTree<V, WE, W> spanningTree = new MutableSpanningTree<V,
WE, W>( weightOperations );
+        final MutableSpanningTree<V, WE, W> spanningTree = new MutableSpanningTree<V,
WE, W>( weightOperations, weightedEdges );
 
         final Set<SuperVertex<V, W, WE, G>> components = new HashSet<SuperVertex<V,
W, WE, G>>( graph.getOrder() );
 
@@ -182,7 +182,7 @@ final class DefaultSpanningTreeAlgorithm
 
         final DisjointSet<V> disjointSet = new DisjointSet<V>();
 
-        final MutableSpanningTree<V, WE, W> spanningTree = new MutableSpanningTree<V,
WE, W>( weightOperations );
+        final MutableSpanningTree<V, WE, W> spanningTree = new MutableSpanningTree<V,
WE, W>( weightOperations, weightedEdges );
 
         // fill the spanning tree with vertices.
         for ( V v : graph.getVertices() )

Modified: commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java?rev=1298196&r1=1298195&r2=1298196&view=diff
==============================================================================
--- commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java
(original)
+++ commons/sandbox/graph/branches/drop-marker-interfaces-feature/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java
Wed Mar  7 23:08:13 2012
@@ -121,7 +121,7 @@ final class DefaultSpanningTreeSourceSel
             }
         }
 
-        final MutableSpanningTree<V, WE, W> res = new MutableSpanningTree<V, WE,
W>( weightOperations );
+        final MutableSpanningTree<V, WE, W> res = new MutableSpanningTree<V, WE,
W>( weightOperations, weightedEdges );
         for ( V v : graph.getVertices() )
         {
             res.addVertex( v );

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=1298196&r1=1298195&r2=1298196&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
Wed Mar  7 23:08:13 2012
@@ -79,7 +79,7 @@ final class ShortestEdges<V, WE, W>
      */
     public SpanningTree<V, WE, W> createSpanningTree()
     {
-        MutableSpanningTree<V, WE, W> spanningTree = new MutableSpanningTree<V,
WE, W>( weightOperations );
+        MutableSpanningTree<V, WE, W> spanningTree = new MutableSpanningTree<V,
WE, W>( weightOperations, weightedEdges );
 
         for ( WE edge : this.predecessors.values() )
         {



Mime
View raw message