Search in sources :

Example 1 with DefaultTopologyVertex

use of org.onosproject.net.topology.DefaultTopologyVertex 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)

Example 2 with DefaultTopologyVertex

use of org.onosproject.net.topology.DefaultTopologyVertex in project onos by opennetworkinglab.

the class DefaultTopology method getDisjointPaths.

/**
 * Computes on-demand the set of shortest disjoint path pairs between
 * source and destination devices.
 *
 * @param src     source device
 * @param dst     destination device
 * @param weigher link weight function
 * @return set of disjoint shortest path pairs
 */
public Set<DisjointPath> getDisjointPaths(DeviceId src, DeviceId dst, LinkWeigher weigher) {
    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();
    }
    GraphPathSearch.Result<TopologyVertex, TopologyEdge> result = SUURBALLE.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) ImmutableSet(com.google.common.collect.ImmutableSet) DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) TopologyEdge(org.onosproject.net.topology.TopologyEdge) GraphPathSearch(org.onlab.graph.GraphPathSearch) DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath) DisjointPath(org.onosproject.net.DisjointPath)

Example 3 with DefaultTopologyVertex

use of org.onosproject.net.topology.DefaultTopologyVertex in project onos by opennetworkinglab.

the class DefaultTopology method getKShortestPaths.

/**
 * Lazily computes on-demand the k-shortest paths between source and
 * destination devices.
 *
 * @param src     source device
 * @param dst     destination device
 * @param weigher link weight function
 * @return stream of k-shortest paths
 */
public Stream<Path> getKShortestPaths(DeviceId src, DeviceId dst, LinkWeigher weigher) {
    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 Stream.empty();
    }
    return LAZY_KSHORTEST.lazyPathSearch(graph, srcV, dstV, weigher).map(this::networkPath);
}
Also used : DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) TopologyVertex(org.onosproject.net.topology.TopologyVertex) DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex)

Example 4 with DefaultTopologyVertex

use of org.onosproject.net.topology.DefaultTopologyVertex in project onos by opennetworkinglab.

the class DefaultTopology method getPaths.

/**
 * Computes on-demand the set of shortest paths between source and
 * destination devices, the set of returned paths will be no more than,
 * maxPaths in size.  The first {@code maxPaths} paths will be returned
 * maintaining any ordering guarantees provided by the underlying
 * (default or if no default is specified {@link DijkstraGraphSearch})
 * search. If returning all paths of a given length would exceed
 * {@code maxPaths} a subset of paths of that length will be returned,
 * which paths will be returned depends on the currently specified
 * {@code GraphPathSearch}. See {@link #setDefaultGraphPathSearch}.
 *
 * @param src      source device
 * @param dst      destination device
 * @param weigher  link weight function
 * @param maxPaths maximum number of paths
 * @return set of shortest paths
 */
public Set<Path> getPaths(DeviceId src, DeviceId dst, LinkWeigher weigher, int maxPaths) {
    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();
    }
    GraphPathSearch.Result<TopologyVertex, TopologyEdge> result = graphPathSearch().search(graph, srcV, dstV, weigher, maxPaths);
    ImmutableSet.Builder<Path> builder = ImmutableSet.builder();
    for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
        builder.add(networkPath(path));
    }
    return builder.build();
}
Also used : DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath) Path(org.onosproject.net.Path) DefaultPath(org.onosproject.net.DefaultPath) DisjointPath(org.onosproject.net.DisjointPath) DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) TopologyVertex(org.onosproject.net.topology.TopologyVertex) ImmutableSet(com.google.common.collect.ImmutableSet) DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) TopologyEdge(org.onosproject.net.topology.TopologyEdge) GraphPathSearch(org.onlab.graph.GraphPathSearch)

Example 5 with DefaultTopologyVertex

use of org.onosproject.net.topology.DefaultTopologyVertex in project onos by opennetworkinglab.

the class DefaultTopology method getKShortestPaths.

/**
 * Computes on-demand the k-shortest paths between source and
 * destination devices.
 * <p>
 * The first {@code maxPaths} paths will be returned
 * in ascending order according to the provided {@code weigher}
 *
 * @param src      source device
 * @param dst      destination device
 * @param weigher  link weight function
 * @param maxPaths maximum number of paths (k)
 * @return set of k-shortest paths
 */
public Set<Path> getKShortestPaths(DeviceId src, DeviceId dst, LinkWeigher weigher, int maxPaths) {
    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();
    }
    return KSHORTEST.search(graph, srcV, dstV, weigher, maxPaths).paths().stream().map(this::networkPath).collect(ImmutableSet.toImmutableSet());
}
Also used : DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) TopologyVertex(org.onosproject.net.topology.TopologyVertex) DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex)

Aggregations

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