Search in sources :

Example 1 with SrlgGraphSearch

use of org.onlab.graph.SrlgGraphSearch in project onos by opennetworkinglab.

the class DefaultTopology method disjointPaths.

/**
 * Computes on-demand the set of shortest disjoint risk groups path pairs
 * between source and destination devices.
 *
 * @param src         source device
 * @param dst         destination device
 * @param weigher     edge weight object
 * @param riskProfile map representing risk groups for each edge
 * @return set of shortest disjoint paths
 */
private Set<DisjointPath> disjointPaths(DeviceId src, DeviceId dst, LinkWeigher weigher, Map<TopologyEdge, Object> riskProfile) {
    DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
    DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
    Set<TopologyVertex> vertices = graph.getVertexes();
    if (!vertices.contains(srcV) || !vertices.contains(dstV)) {
        // src or dst not part of the current graph
        return ImmutableSet.of();
    }
    SrlgGraphSearch<TopologyVertex, TopologyEdge> srlg = new SrlgGraphSearch<>(riskProfile);
    GraphPathSearch.Result<TopologyVertex, TopologyEdge> result = srlg.search(graph, srcV, dstV, weigher, defaultMaxPaths);
    ImmutableSet.Builder<DisjointPath> builder = ImmutableSet.builder();
    for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
        DisjointPath disjointPath = networkDisjointPath((DisjointPathPair<TopologyVertex, TopologyEdge>) path);
        if (disjointPath.backup() != null) {
            builder.add(disjointPath);
        }
    }
    return builder.build();
}
Also used : DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) TopologyVertex(org.onosproject.net.topology.TopologyVertex) TopologyEdge(org.onosproject.net.topology.TopologyEdge) GraphPathSearch(org.onlab.graph.GraphPathSearch) ImmutableSet(com.google.common.collect.ImmutableSet) DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) SrlgGraphSearch(org.onlab.graph.SrlgGraphSearch) DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath) DisjointPath(org.onosproject.net.DisjointPath)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)1 GraphPathSearch (org.onlab.graph.GraphPathSearch)1 SrlgGraphSearch (org.onlab.graph.SrlgGraphSearch)1 DefaultDisjointPath (org.onosproject.net.DefaultDisjointPath)1 DisjointPath (org.onosproject.net.DisjointPath)1 DefaultTopologyVertex (org.onosproject.net.topology.DefaultTopologyVertex)1 TopologyEdge (org.onosproject.net.topology.TopologyEdge)1 TopologyVertex (org.onosproject.net.topology.TopologyVertex)1