commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1134818 - /commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/WeightedGraphWrapper.java
Date Sat, 11 Jun 2011 23:15:55 GMT
Author: simonetripodi
Date: Sat Jun 11 23:15:55 2011
New Revision: 1134818

URL: http://svn.apache.org/viewvc?rev=1134818&view=rev
Log:
generified Vertex/Edge

Modified:
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/WeightedGraphWrapper.java

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/WeightedGraphWrapper.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/WeightedGraphWrapper.java?rev=1134818&r1=1134817&r2=1134818&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/WeightedGraphWrapper.java
(original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/WeightedGraphWrapper.java
Sat Jun 11 23:15:55 2011
@@ -26,19 +26,22 @@ import org.apache.commons.graph.*;
 
 /**
  * Description of the Class
+ *
+ * @param <V> the Graph vertices type
+ * @param <E> the Graph edges type
  */
-public class WeightedGraphWrapper
-     extends GraphWrapper
-     implements WeightedGraph
+public class WeightedGraphWrapper<V extends Vertex, WE extends WeightedEdge>
+     extends GraphWrapper<V, WE>
+     implements WeightedGraph<V, WE>
 {
-    private Map weights = new HashMap();// EDGE X WEIGHT
+    private Map<WE, Number> weights = new HashMap<WE, Number>(); // EDGE X WEIGHT
 
     /**
      * Constructor for the WeightedGraphWrapper object
      *
      * @param graph
      */
-    public WeightedGraphWrapper(Graph graph)
+    public WeightedGraphWrapper(Graph<V, WE> graph)
     {
         super(graph);
     }
@@ -46,11 +49,11 @@ public class WeightedGraphWrapper
     /**
      * Gets the weight attribute of the WeightedGraphWrapper object
      */
-    public double getWeight(Edge e)
+    public Number getWeight(WE e)
     {
         if (weights.containsKey(e))
         {
-            return ((Double) weights.get(e)).doubleValue();
+            return weights.get(e);
         }
         else
         {
@@ -61,9 +64,9 @@ public class WeightedGraphWrapper
     /**
      * Sets the weight attribute of the WeightedGraphWrapper object
      */
-    public void setWeight(Edge e, double weight)
+    public void setWeight(WE e, Number weight)
     {
-        weights.put(e, new Double(weight));
+        weights.put(e, weight);
     }
 
 }



Mime
View raw message