Vector cost proposed to TST on 2016-07-13

First part implemented: weight interface introduced and integrated, default weight implementation added.

Change-Id: Ia46f1b44139069aa171a3c13faf168351bd7cc56
diff --git a/core/api/src/main/java/org/onosproject/net/DefaultDisjointPath.java b/core/api/src/main/java/org/onosproject/net/DefaultDisjointPath.java
index c4e0398..b68110d 100644
--- a/core/api/src/main/java/org/onosproject/net/DefaultDisjointPath.java
+++ b/core/api/src/main/java/org/onosproject/net/DefaultDisjointPath.java
@@ -16,6 +16,7 @@
 
 package org.onosproject.net;
 
+import org.onlab.graph.Weight;
 import org.onosproject.net.provider.ProviderId;
 
 import java.util.List;
@@ -40,7 +41,7 @@
      */
     public DefaultDisjointPath(ProviderId providerId, DefaultPath path1, DefaultPath path2) {
         // Note: cost passed to super will never be used
-        super(providerId, path1.links(), path1.cost());
+        super(providerId, path1.links(), path1.weight());
         this.path1 = path1;
         this.path2 = path2;
     }
@@ -66,10 +67,12 @@
 
     @Override
     public double cost() {
-        if (usingPath1) {
-            return path1.cost();
-        }
-        return path2.cost();
+        return usingPath1 ? path1.cost() : path2.cost();
+    }
+
+    @Override
+    public Weight weight() {
+        return usingPath1 ? path1.weight() : path2.weight();
     }
 
     @Override
diff --git a/core/api/src/main/java/org/onosproject/net/DefaultPath.java b/core/api/src/main/java/org/onosproject/net/DefaultPath.java
index e4c3d8c..79677ac 100644
--- a/core/api/src/main/java/org/onosproject/net/DefaultPath.java
+++ b/core/api/src/main/java/org/onosproject/net/DefaultPath.java
@@ -17,6 +17,8 @@
 
 import com.google.common.base.MoreObjects;
 import com.google.common.collect.ImmutableList;
+import org.onlab.graph.ScalarWeight;
+import org.onlab.graph.Weight;
 import org.onosproject.net.provider.ProviderId;
 
 import java.util.List;
@@ -31,7 +33,27 @@
 public class DefaultPath extends DefaultLink implements Path {
 
     private final List<Link> links;
-    private final double cost;
+    private final Weight cost;
+
+    /**
+     * Creates a path from the specified source and destination using the
+     * supplied list of links.
+     *
+     * @param providerId provider identity
+     * @param links      contiguous links that comprise the path
+     * @param cost       unit-less path cost
+     * @param annotations optional key/value annotations
+     *
+     * @deprecated in Junco (1.9.0)
+     */
+    @Deprecated
+    public DefaultPath(ProviderId providerId, List<Link> links, double cost,
+                       Annotations... annotations) {
+        super(providerId, source(links), destination(links), Type.INDIRECT,
+                State.ACTIVE, annotations);
+        this.links = ImmutableList.copyOf(links);
+        this.cost = new ScalarWeight(cost);
+    }
 
     /**
      * Creates a path from the specified source and destination using the
@@ -42,7 +64,7 @@
      * @param cost       unit-less path cost
      * @param annotations optional key/value annotations
      */
-    public DefaultPath(ProviderId providerId, List<Link> links, double cost,
+    public DefaultPath(ProviderId providerId, List<Link> links, Weight cost,
                        Annotations... annotations) {
         super(providerId, source(links), destination(links), Type.INDIRECT, State.ACTIVE, annotations);
         this.links = ImmutableList.copyOf(links);
@@ -56,6 +78,14 @@
 
     @Override
     public double cost() {
+        if (cost instanceof ScalarWeight) {
+            return ((ScalarWeight) cost).value();
+        }
+        return 0;
+    }
+
+    @Override
+    public Weight weight() {
         return cost;
     }
 
diff --git a/core/api/src/main/java/org/onosproject/net/Path.java b/core/api/src/main/java/org/onosproject/net/Path.java
index fdff4e0..13fae0a 100644
--- a/core/api/src/main/java/org/onosproject/net/Path.java
+++ b/core/api/src/main/java/org/onosproject/net/Path.java
@@ -15,13 +15,16 @@
  */
 package org.onosproject.net;
 
+import org.onlab.graph.Weight;
+
 import java.util.List;
 
 /**
  * Representation of a contiguous directed path in a network. Path comprises
  * of a sequence of links, where adjacent links must share the same device,
  * meaning that destination of the source of one link must coincide with the
- * destination of the previous link.
+ * destination of the previous link. Path weight (cost) is an aggregation
+ * of the weights of the links the path consists of.
  */
 public interface Path extends Link {
 
@@ -36,7 +39,17 @@
      * Returns the path cost as a unit-less value.
      *
      * @return unit-less path cost
+     *
+     * @deprecated in Junco (1.9.0), use weight() instead
      */
+    @Deprecated
     double cost();
 
+    /**
+     * Returns the path cost as an weight instance.
+     *
+     * @return weight path cost
+     */
+    Weight weight();
+
 }
diff --git a/core/api/src/main/java/org/onosproject/net/topology/AbstractPathService.java b/core/api/src/main/java/org/onosproject/net/topology/AbstractPathService.java
index 8b24cbb..2c43fc7 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/AbstractPathService.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/AbstractPathService.java
@@ -18,6 +18,7 @@
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
+import org.onlab.graph.Weight;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DefaultDisjointPath;
 import org.onosproject.net.DefaultEdgeLink;
@@ -40,6 +41,7 @@
 import java.util.Set;
 
 import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onosproject.net.topology.AdapterLinkWeigher.adapt;
 
 /**
  * Helper class for path service.
@@ -56,15 +58,25 @@
     private static final ProviderId PID = new ProviderId("core", "org.onosproject.core");
     private static final PortNumber P0 = PortNumber.portNumber(0);
 
+    protected static final LinkWeigher DEFAULT_WEIGHER =
+            adapt(new HopCountLinkWeight());
+
     protected TopologyService topologyService;
 
     protected HostService hostService;
 
     @Override
     public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
+        return getPaths(src, dst, adapt(weight));
+    }
+
+    @Override
+    public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
         checkNotNull(src, ELEMENT_ID_NULL);
         checkNotNull(dst, ELEMENT_ID_NULL);
 
+        LinkWeigher internalWeigher = weigher != null ? weigher : DEFAULT_WEIGHER;
+
         // Get the source and destination edge locations
         EdgeLink srcEdge = getEdgeLink(src, true);
         EdgeLink dstEdge = getEdgeLink(dst, false);
@@ -80,24 +92,30 @@
         // If the source and destination are on the same edge device, there
         // is just one path, so build it and return it.
         if (srcDevice.equals(dstDevice)) {
-            return edgeToEdgePaths(srcEdge, dstEdge);
+            return edgeToEdgePaths(srcEdge, dstEdge, internalWeigher);
         }
 
         // Otherwise get all paths between the source and destination edge
         // devices.
         Topology topology = topologyService.currentTopology();
-        Set<Path> paths = weight == null ?
-                topologyService.getPaths(topology, srcDevice, dstDevice) :
-                topologyService.getPaths(topology, srcDevice, dstDevice, weight);
+        Set<Path> paths = topologyService.getPaths(topology, srcDevice,
+                dstDevice, internalWeigher);
 
-        return edgeToEdgePaths(srcEdge, dstEdge, paths);
+        return edgeToEdgePaths(srcEdge, dstEdge, paths, internalWeigher);
     }
 
     @Override
     public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
+        return getDisjointPaths(src, dst, adapt(weight));
+    }
+
+    @Override
+    public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
         checkNotNull(src, ELEMENT_ID_NULL);
         checkNotNull(dst, ELEMENT_ID_NULL);
 
+        LinkWeigher internalWeigher = weigher != null ? weigher : DEFAULT_WEIGHER;
+
         // Get the source and destination edge locations
         EdgeLink srcEdge = getEdgeLink(src, true);
         EdgeLink dstEdge = getEdgeLink(dst, false);
@@ -113,25 +131,32 @@
         // If the source and destination are on the same edge device, there
         // is just one path, so build it and return it.
         if (srcDevice.equals(dstDevice)) {
-            return edgeToEdgePathsDisjoint(srcEdge, dstEdge);
+            return edgeToEdgePathsDisjoint(srcEdge, dstEdge, internalWeigher);
         }
 
         // Otherwise get all paths between the source and destination edge
         // devices.
         Topology topology = topologyService.currentTopology();
-        Set<DisjointPath> paths = weight == null ?
-                topologyService.getDisjointPaths(topology, srcDevice, dstDevice) :
-                topologyService.getDisjointPaths(topology, srcDevice, dstDevice, weight);
+        Set<DisjointPath> paths = topologyService.getDisjointPaths(topology,
+                srcDevice, dstDevice, internalWeigher);
 
-        return edgeToEdgePathsDisjoint(srcEdge, dstEdge, paths);
+        return edgeToEdgePathsDisjoint(srcEdge, dstEdge, paths, internalWeigher);
     }
 
     @Override
     public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight,
                                               Map<Link, Object> riskProfile) {
+        return getDisjointPaths(src, dst, adapt(weight), riskProfile);
+    }
+
+    @Override
+    public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
+                                              LinkWeigher weigher, Map<Link, Object> riskProfile) {
         checkNotNull(src, ELEMENT_ID_NULL);
         checkNotNull(dst, ELEMENT_ID_NULL);
 
+        LinkWeigher internalWeigher = weigher != null ? weigher : DEFAULT_WEIGHER;
+
         // Get the source and destination edge locations
         EdgeLink srcEdge = getEdgeLink(src, true);
         EdgeLink dstEdge = getEdgeLink(dst, false);
@@ -147,17 +172,16 @@
         // If the source and destination are on the same edge device, there
         // is just one path, so build it and return it.
         if (srcDevice.equals(dstDevice)) {
-            return edgeToEdgePathsDisjoint(srcEdge, dstEdge);
+            return edgeToEdgePathsDisjoint(srcEdge, dstEdge, internalWeigher);
         }
 
         // Otherwise get all paths between the source and destination edge
         // devices.
         Topology topology = topologyService.currentTopology();
-        Set<DisjointPath> paths = weight == null ?
-                topologyService.getDisjointPaths(topology, srcDevice, dstDevice, riskProfile) :
-                topologyService.getDisjointPaths(topology, srcDevice, dstDevice, weight, riskProfile);
+        Set<DisjointPath> paths = topologyService.getDisjointPaths(topology,
+                srcDevice, dstDevice, internalWeigher, riskProfile);
 
-        return edgeToEdgePathsDisjoint(srcEdge, dstEdge, paths);
+        return edgeToEdgePathsDisjoint(srcEdge, dstEdge, paths, internalWeigher);
     }
 
     // Finds the host edge link if the element ID is a host id of an existing
@@ -178,61 +202,63 @@
 
     // Produces a set of edge-to-edge paths using the set of infrastructure
     // paths and the given edge links.
-    private Set<Path> edgeToEdgePaths(EdgeLink srcLink, EdgeLink dstLink) {
+    private Set<Path> edgeToEdgePaths(EdgeLink srcLink, EdgeLink dstLink, LinkWeigher weigher) {
         Set<Path> endToEndPaths = Sets.newHashSetWithExpectedSize(1);
-        endToEndPaths.add(edgeToEdgePath(srcLink, dstLink, null));
+        endToEndPaths.add(edgeToEdgePath(srcLink, dstLink, null, weigher));
         return endToEndPaths;
     }
 
     // Produces a set of edge-to-edge paths using the set of infrastructure
     // paths and the given edge links.
-    private Set<Path> edgeToEdgePaths(EdgeLink srcLink, EdgeLink dstLink, Set<Path> paths) {
+    private Set<Path> edgeToEdgePaths(EdgeLink srcLink, EdgeLink dstLink, Set<Path> paths,
+                                      LinkWeigher weigher) {
         Set<Path> endToEndPaths = Sets.newHashSetWithExpectedSize(paths.size());
         for (Path path : paths) {
-            endToEndPaths.add(edgeToEdgePath(srcLink, dstLink, path));
+            endToEndPaths.add(edgeToEdgePath(srcLink, dstLink, path, weigher));
         }
         return endToEndPaths;
     }
 
-    private Set<DisjointPath> edgeToEdgePathsDisjoint(EdgeLink srcLink, EdgeLink dstLink) {
+    private Set<DisjointPath> edgeToEdgePathsDisjoint(EdgeLink srcLink, EdgeLink dstLink, LinkWeigher weigher) {
         Set<DisjointPath> endToEndPaths = Sets.newHashSetWithExpectedSize(1);
-        endToEndPaths.add(edgeToEdgePathD(srcLink, dstLink, null));
+        endToEndPaths.add(edgeToEdgePathD(srcLink, dstLink, null, weigher));
         return endToEndPaths;
     }
 
     private Set<DisjointPath> edgeToEdgePathsDisjoint(EdgeLink srcLink, EdgeLink dstLink,
-                                                             Set<DisjointPath> paths) {
+                                                             Set<DisjointPath> paths, LinkWeigher weigher) {
         Set<DisjointPath> endToEndPaths = Sets.newHashSetWithExpectedSize(paths.size());
         for (DisjointPath path : paths) {
-            endToEndPaths.add(edgeToEdgePathD(srcLink, dstLink, path));
+            endToEndPaths.add(edgeToEdgePathD(srcLink, dstLink, path, weigher));
         }
         return endToEndPaths;
     }
 
     // Produces a direct edge-to-edge path.
-    private Path edgeToEdgePath(EdgeLink srcLink, EdgeLink dstLink, Path path) {
+    private Path edgeToEdgePath(EdgeLink srcLink, EdgeLink dstLink, Path path, LinkWeigher weigher) {
         List<Link> links = Lists.newArrayListWithCapacity(2);
-        double cost = 0;
+        Weight cost = weigher.getInitialWeight();
 
         // Add source and destination edge links only if they are real and
         // add the infrastructure path only if it is not null.
         if (srcLink != NOT_HOST) {
             links.add(srcLink);
-            cost++;
+            cost = cost.merge(weigher.weight(new DefaultTopologyEdge(null, null, srcLink)));
         }
         if (path != null) {
             links.addAll(path.links());
-            cost += path.cost();
+            cost = cost.merge(path.weight());
         }
         if (dstLink != NOT_HOST) {
             links.add(dstLink);
-            cost++;
+            cost = cost.merge(weigher.weight(new DefaultTopologyEdge(null, null, srcLink)));
         }
         return new DefaultPath(PID, links, cost);
     }
 
     // Produces a direct edge-to-edge path.
-    private DisjointPath edgeToEdgePathD(EdgeLink srcLink, EdgeLink dstLink, DisjointPath path) {
+    private DisjointPath edgeToEdgePathD(EdgeLink srcLink, EdgeLink dstLink, DisjointPath path,
+                                         LinkWeigher weigher) {
         Path primary = null;
         Path backup = null;
         if (path != null) {
@@ -240,10 +266,12 @@
             backup = path.backup();
         }
         if (backup == null) {
-        return new DefaultDisjointPath(PID, (DefaultPath) edgeToEdgePath(srcLink, dstLink, primary));
+        return new DefaultDisjointPath(PID,
+                (DefaultPath) edgeToEdgePath(srcLink, dstLink, primary, weigher));
         }
-        return new DefaultDisjointPath(PID, (DefaultPath) edgeToEdgePath(srcLink, dstLink, primary),
-                                       (DefaultPath) edgeToEdgePath(srcLink, dstLink, backup));
+        return new DefaultDisjointPath(PID,
+                (DefaultPath) edgeToEdgePath(srcLink, dstLink, primary, weigher),
+                (DefaultPath) edgeToEdgePath(srcLink, dstLink, backup, weigher));
     }
 
 
diff --git a/core/api/src/main/java/org/onosproject/net/topology/AdapterLinkWeigher.java b/core/api/src/main/java/org/onosproject/net/topology/AdapterLinkWeigher.java
new file mode 100644
index 0000000..1bb2729
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/topology/AdapterLinkWeigher.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed 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.
+ */
+
+package org.onosproject.net.topology;
+
+import org.onlab.graph.DefaultEdgeWeigher;
+import org.onlab.graph.ScalarWeight;
+import org.onlab.graph.Weight;
+
+/**
+ * Wrapper which transforms double-based link weigher to {@link Weight}-based
+ * link weigher.
+ */
+public final class AdapterLinkWeigher
+        extends DefaultEdgeWeigher<TopologyVertex, TopologyEdge>
+        implements LinkWeigher {
+
+    private final LinkWeight doubleWeigher;
+
+    private AdapterLinkWeigher(LinkWeight doubleWeigher) {
+        this.doubleWeigher = doubleWeigher;
+    }
+
+    @Override
+    public Weight weight(TopologyEdge edge) {
+        return new ScalarWeight(doubleWeigher.weight(edge));
+    }
+
+    /**
+     * Transforms double-based link weigher to {@link Weight}-based weigher.
+     *
+     * @param lw double-based weigher
+     * @return {@link Weight}-based weigher
+     */
+    public static LinkWeigher adapt(LinkWeight lw) {
+        return lw == null ? null : new AdapterLinkWeigher(lw);
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/topology/LinkWeigher.java b/core/api/src/main/java/org/onosproject/net/topology/LinkWeigher.java
new file mode 100644
index 0000000..9008811
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/topology/LinkWeigher.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed 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.
+ */
+
+package org.onosproject.net.topology;
+
+import org.onlab.graph.EdgeWeigher;
+
+/**
+ * Entity capable of determining cost or weight of a specified topology
+ * graph edge. Returns {@link org.onlab.graph.Weight} instances.
+ */
+public interface LinkWeigher extends EdgeWeigher<TopologyVertex, TopologyEdge> {
+}
diff --git a/core/api/src/main/java/org/onosproject/net/topology/LinkWeight.java b/core/api/src/main/java/org/onosproject/net/topology/LinkWeight.java
index 99fa38c..22eb7d1 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/LinkWeight.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/LinkWeight.java
@@ -15,11 +15,19 @@
  */
 package org.onosproject.net.topology;
 
-import org.onlab.graph.EdgeWeight;
-
 /**
  * Entity capable of determining cost or weight of a specified topology
  * graph edge.
+ * @deprecated in Junco (1.9.0), use {@link LinkWeigher} instead
  */
-public interface LinkWeight extends EdgeWeight<TopologyVertex, TopologyEdge> {
+@Deprecated
+public interface LinkWeight {
+
+    /**
+     * Returns the weight of the given edge.
+     *
+     * @param edge edge to be weighed
+     * @return edge weight
+     */
+    double weight(TopologyEdge edge);
 }
diff --git a/core/api/src/main/java/org/onosproject/net/topology/PathAdminService.java b/core/api/src/main/java/org/onosproject/net/topology/PathAdminService.java
index 0214e57..d88d729 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/PathAdminService.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/PathAdminService.java
@@ -29,10 +29,22 @@
      * used.
      *
      * @param linkWeight default link-weight function
+     *
+     * @deprecated in Junco (1.9.0), use setDefaultLinkWeigher() instead
      */
+    @Deprecated
     void setDefaultLinkWeight(LinkWeight linkWeight);
 
     /**
+     * Sets the specified link-weight function to be used as a default.
+     * If null is specified, the builtin default hop-count link-weight will be
+     * used.
+     *
+     * @param linkWeigher link-weight function to be used as default
+     */
+    void setDefaultLinkWeigher(LinkWeigher linkWeigher);
+
+    /**
      * Sets the specified graph path search algorightm to be used as a default.
      * If null is specified, the builtin default all-shortest-paths Dijkstra
      * algorithm will be used.
diff --git a/core/api/src/main/java/org/onosproject/net/topology/PathService.java b/core/api/src/main/java/org/onosproject/net/topology/PathService.java
index 6ed4799..adfca3d 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/PathService.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/PathService.java
@@ -49,10 +49,25 @@
      * @param dst    destination element
      * @param weight edge-weight entity
      * @return set of all shortest paths between the two element
+     *
+     * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
      */
+    @Deprecated
     Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight);
 
     /**
+     * Returns the set of all shortest paths between the specified source and
+     * destination network elements.  The path is computed using the supplied
+     * edge-weight function.
+     *
+     * @param src     source element
+     * @param dst     destination element
+     * @param weigher edge-weight entity
+     * @return set of all shortest paths between the two element
+     */
+    Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weigher);
+
+    /**
      * Returns the set of all disjoint shortest path pairs between the
      * specified source and destination elements. The path is computed using
      * the default edge-weight function, which by default is hop-count.
@@ -72,12 +87,28 @@
      * @param dst    destination device
      * @param weight edge-weight entity
      * @return set of all shortest paths between the two devices
+     *
+     * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
      */
+    @Deprecated
     Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
                                        LinkWeight weight);
 
     /**
      * Returns the set of all disjoint shortest path pairs between the
+     * specified source and destination elements. The path is computed using
+     * the supplied edge-weight function.
+     *
+     * @param src     source device
+     * @param dst     destination device
+     * @param weigher edge-weight entity
+     * @return set of all shortest paths between the two devices
+     */
+    Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
+                                       LinkWeigher weigher);
+
+    /**
+     * Returns the set of all disjoint shortest path pairs between the
      * specified source and destination elements and taking into consideration
      * the provided risk profile. The path is computed using the default
      * edge-weight function, which by default is hop-count.
@@ -101,9 +132,28 @@
      * @param weight      edge-weight entity
      * @param riskProfile map of edges to risk profiles
      * @return set of all shortest paths between the two devices
+     *
+     * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
      */
+    @Deprecated
     Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
                                        LinkWeight weight,
                                        Map<Link, Object> riskProfile);
 
+    /**
+     * Returns the set of all disjoint shortest path pairs between the
+     * specified source and destination elements and taking into consideration
+     * the provided risk profile. The path is computed using the supplied
+     * edge-weight function.
+     *
+     * @param src         source device
+     * @param dst         destination device
+     * @param weigher     edge-weight entity
+     * @param riskProfile map of edges to risk profiles
+     * @return set of all shortest paths between the two devices
+     */
+    Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
+                                       LinkWeigher weigher,
+                                       Map<Link, Object> riskProfile);
+
 }
diff --git a/core/api/src/main/java/org/onosproject/net/topology/TopologyService.java b/core/api/src/main/java/org/onosproject/net/topology/TopologyService.java
index e4504c5..13d1842 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/TopologyService.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/TopologyService.java
@@ -109,11 +109,27 @@
      * @param dst      destination device
      * @param weight   edge-weight entity
      * @return set of all shortest paths between the two devices
+     *
+     * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
      */
+    @Deprecated
     Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
                        LinkWeight weight);
 
     /**
+     * Returns the set of all shortest paths, computed using the supplied
+     * edge-weight entity, between the specified source and destination devices.
+     *
+     * @param topology topology descriptor
+     * @param src      source device
+     * @param dst      destination device
+     * @param weigher  edge-weight entity
+     * @return set of all shortest paths between the two devices
+     */
+    Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
+                       LinkWeigher weigher);
+
+    /**
      * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
      * between the specified source and destination devices.
      *
@@ -133,11 +149,27 @@
      * @param dst      destination device
      * @param weight   edge-weight entity
      * @return set of all shortest paths between the two devices
+     *
+     * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
      */
+    @Deprecated
     Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
                                        LinkWeight weight);
 
     /**
+     * Returns the set of all disjoint shortest path pairs, computed using the supplied
+     * edge-weight entity, between the specified source and destination devices.
+     *
+     * @param topology topology descriptor
+     * @param src      source device
+     * @param dst      destination device
+     * @param weigher  edge-weight entity
+     * @return set of all shortest paths between the two devices
+     */
+    Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
+                                       LinkWeigher weigher);
+
+    /**
      * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
      * between the specified source and destination devices.
      *
@@ -160,11 +192,28 @@
      * @param weight      edge-weight entity
      * @param riskProfile map of edges to risk profiles
      * @return set of all shortest paths between the two devices
+     *
+     * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
      */
+    @Deprecated
     Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
                                        LinkWeight weight, Map<Link, Object> riskProfile);
 
     /**
+     * Returns the set of all disjoint shortest path pairs, precomputed in terms of hop-count,
+     * between the specified source and destination devices.
+     *
+     * @param topology    topology descriptor
+     * @param src         source device
+     * @param dst         destination device
+     * @param weigher     edge-weight entity
+     * @param riskProfile map of edges to risk profiles
+     * @return set of all shortest paths between the two devices
+     */
+    Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
+                                       LinkWeigher weigher, Map<Link, Object> riskProfile);
+
+    /**
      * Indicates whether the specified connection point is part of the network
      * infrastructure or part of network edge.
      *
diff --git a/core/api/src/main/java/org/onosproject/net/topology/TopologyStore.java b/core/api/src/main/java/org/onosproject/net/topology/TopologyStore.java
index 61ab526..907beb2 100644
--- a/core/api/src/main/java/org/onosproject/net/topology/TopologyStore.java
+++ b/core/api/src/main/java/org/onosproject/net/topology/TopologyStore.java
@@ -109,11 +109,26 @@
      * @param dst      destination device
      * @param weight   link weight function
      * @return set of shortest paths
+     *
+     * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
      */
+    @Deprecated
     Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
                        LinkWeight weight);
 
     /**
+     * Computes and returns the set of shortest paths between src and dest.
+     *
+     * @param topology topology descriptor
+     * @param src      source device
+     * @param dst      destination device
+     * @param weigher  link weight function
+     * @return set of shortest paths
+     */
+    Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
+                       LinkWeigher weigher);
+
+    /**
      * Computes and returns the set of disjoint shortest path pairs
      * between src and dst.
      *
@@ -122,7 +137,10 @@
      * @param dst      destination device
      * @param weight   link weight function
      * @return set of shortest paths
+     *
+     * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
      */
+    @Deprecated
     Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
                                        LinkWeight weight);
 
@@ -133,6 +151,19 @@
      * @param topology topology descriptor
      * @param src      source device
      * @param dst      destination device
+     * @param weigher  link weight function
+     * @return set of shortest paths
+     */
+    Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
+                                       LinkWeigher weigher);
+
+    /**
+     * Computes and returns the set of disjoint shortest path pairs
+     * between src and dst.
+     *
+     * @param topology topology descriptor
+     * @param src      source device
+     * @param dst      destination device
      * @return set of shortest paths
      */
     Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst);
@@ -141,24 +172,42 @@
      * Computes and returns the set of SRLG disjoint shortest path pairs between source
      * and dst, given a mapping of edges to SRLG risk groups.
      *
-     * @param topology topology descriptor
-     * @param src      source device
-     * @param dst      destination device
-     * @param weight   link weight function
-     * @param riskProfile   map of edges to objects. Edges that map to the same object will
+     * @param topology    topology descriptor
+     * @param src         source device
+     * @param dst         destination device
+     * @param weight      link weight function
+     * @param riskProfile map of edges to objects. Edges that map to the same object will
      * be treated as if they were in the same risk group.
      * @return set of shortest paths
+     *
+     * @deprecated in Junco (1.9.0), use version with LinkWeigher instead
      */
+    @Deprecated
     Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
                                        LinkWeight weight, Map<Link, Object> riskProfile);
 
     /**
+     * Computes and returns the set of SRLG disjoint shortest path pairs between source
+     * and dst, given a mapping of edges to SRLG risk groups.
+     *
+     * @param topology    topology descriptor
+     * @param src         source device
+     * @param dst         destination device
+     * @param weigher     link weight function
+     * @param riskProfile map of edges to objects. Edges that map to the same object will
+     * be treated as if they were in the same risk group.
+     * @return set of shortest paths
+     */
+    Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
+                                       LinkWeigher weigher, Map<Link, Object> riskProfile);
+
+    /**
      * Returns the set of pre-computed SRLG shortest paths between src and dest.
      *
-     * @param topology topology descriptor
-     * @param src      source device
-     * @param dst      destination device
-     * @param riskProfile   map of edges to objects. Edges that map to the same object will
+     * @param topology    topology descriptor
+     * @param src         source device
+     * @param dst         destination device
+     * @param riskProfile map of edges to objects. Edges that map to the same object will
      * be treated as if they were in the same risk group.
      * @return set of shortest paths
      */
diff --git a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
index 931ac72..a944ca6 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
@@ -16,6 +16,7 @@
 package org.onosproject.net.intent;
 
 import com.google.common.base.MoreObjects;
+import org.onlab.graph.Weight;
 import org.onlab.util.Bandwidth;
 import org.onosproject.core.DefaultGroupId;
 import org.onosproject.core.GroupId;
@@ -46,7 +47,7 @@
 import org.onosproject.net.resource.ResourceService;
 import org.onosproject.net.topology.DefaultTopologyEdge;
 import org.onosproject.net.topology.DefaultTopologyVertex;
-import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.LinkWeigher;
 import org.onosproject.net.topology.PathServiceAdapter;
 import org.onosproject.net.topology.TopologyVertex;
 import org.onosproject.store.Timestamp;
@@ -159,19 +160,19 @@
         }
 
         @Override
-        public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
-            final Set<Path> paths = getPaths(src, dst);
+        public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
+            Set<Path> paths = getPaths(src, dst);
 
             for (Path path : paths) {
-                final DeviceId srcDevice = path.src().elementId() instanceof DeviceId ? path.src().deviceId() : null;
-                final DeviceId dstDevice = path.dst().elementId() instanceof DeviceId ? path.dst().deviceId() : null;
+                DeviceId srcDevice = path.src().elementId() instanceof DeviceId ? path.src().deviceId() : null;
+                DeviceId dstDevice = path.dst().elementId() instanceof DeviceId ? path.dst().deviceId() : null;
                 if (srcDevice != null && dstDevice != null) {
-                    final TopologyVertex srcVertex = new DefaultTopologyVertex(srcDevice);
-                    final TopologyVertex dstVertex = new DefaultTopologyVertex(dstDevice);
-                    final Link link = link(src.toString(), 1, dst.toString(), 1);
+                    TopologyVertex srcVertex = new DefaultTopologyVertex(srcDevice);
+                    TopologyVertex dstVertex = new DefaultTopologyVertex(dstDevice);
+                    Link link = link(src.toString(), 1, dst.toString(), 1);
 
-                    final double weightValue = weight.weight(new DefaultTopologyEdge(srcVertex, dstVertex, link));
-                    if (weightValue < 0) {
+                    Weight weightValue = weigher.weight(new DefaultTopologyEdge(srcVertex, dstVertex, link));
+                    if (weightValue.isNegative()) {
                         return new HashSet<>();
                     }
                 }
@@ -220,7 +221,7 @@
         }
 
         @Override
-        public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
+        public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
             final Set<Path> paths = getPaths(src, dst);
 
             for (Path path : paths) {
@@ -231,8 +232,8 @@
                     final TopologyVertex dstVertex = new DefaultTopologyVertex(dstDevice);
                     final Link link = link(src.toString(), 1, dst.toString(), 1);
 
-                    final double weightValue = weight.weight(new DefaultTopologyEdge(srcVertex, dstVertex, link));
-                    if (weightValue < 0) {
+                    final Weight weightValue = weigher.weight(new DefaultTopologyEdge(srcVertex, dstVertex, link));
+                    if (weightValue.isNegative()) {
                         return new HashSet<>();
                     }
                 }
diff --git a/core/api/src/test/java/org/onosproject/net/topology/PathServiceAdapter.java b/core/api/src/test/java/org/onosproject/net/topology/PathServiceAdapter.java
index eecb73e..f0494b1 100644
--- a/core/api/src/test/java/org/onosproject/net/topology/PathServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/net/topology/PathServiceAdapter.java
@@ -38,12 +38,25 @@
     }
 
     @Override
+    public Set<Path> getPaths(ElementId src, ElementId dst,
+                              LinkWeigher weigher) {
+        return null;
+    }
+
+    @Override
     public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst) {
         return null;
     }
 
     @Override
-    public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeight weight) {
+    public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
+                                              LinkWeight weight) {
+        return null;
+    }
+
+    @Override
+    public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
+                                              LinkWeigher weigher) {
         return null;
     }
 
@@ -59,4 +72,11 @@
                                               Map<Link, Object> riskProfile) {
         return null;
     }
+
+    @Override
+    public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
+                                              LinkWeigher weigher,
+                                              Map<Link, Object> riskProfile) {
+        return null;
+    }
 }
diff --git a/core/api/src/test/java/org/onosproject/net/topology/TopologyServiceAdapter.java b/core/api/src/test/java/org/onosproject/net/topology/TopologyServiceAdapter.java
index f86bb3b..79ec17c 100644
--- a/core/api/src/test/java/org/onosproject/net/topology/TopologyServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/net/topology/TopologyServiceAdapter.java
@@ -54,12 +54,14 @@
     }
 
     @Override
-    public Set<DeviceId> getClusterDevices(Topology topology, TopologyCluster cluster) {
+    public Set<DeviceId> getClusterDevices(Topology topology,
+                                           TopologyCluster cluster) {
         return null;
     }
 
     @Override
-    public Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster) {
+    public Set<Link> getClusterLinks(Topology topology,
+                                     TopologyCluster cluster) {
         return null;
     }
 
@@ -69,17 +71,26 @@
     }
 
     @Override
-    public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
+    public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
+                              LinkWeight weight) {
         return null;
     }
 
     @Override
-    public boolean isInfrastructure(Topology topology, ConnectPoint connectPoint) {
+    public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
+                              LinkWeigher weigher) {
+        return null;
+    }
+
+    @Override
+    public boolean isInfrastructure(Topology topology,
+                                    ConnectPoint connectPoint) {
         return false;
     }
 
     @Override
-    public boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint) {
+    public boolean isBroadcastPoint(Topology topology,
+                                    ConnectPoint connectPoint) {
         return false;
     }
 
@@ -92,18 +103,28 @@
     }
 
     @Override
-    public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst) {
+    public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
+                                              DeviceId dst) {
         return null;
     }
 
     @Override
     public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
-                                              DeviceId dst, LinkWeight weight) {
+                                              DeviceId dst,
+                                              LinkWeight weight) {
         return null;
     }
 
     @Override
-    public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst,
+    public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
+                                              DeviceId dst,
+                                              LinkWeigher weigher) {
+        return null;
+    }
+
+    @Override
+    public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
+                                              DeviceId dst,
                                               Map<Link, Object> riskProfile) {
         return null;
     }
@@ -115,4 +136,12 @@
         return null;
     }
 
+    @Override
+    public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
+                                              DeviceId dst,
+                                              LinkWeigher weigher,
+                                              Map<Link, Object> riskProfile) {
+        return null;
+    }
+
 }