Search in sources :

Example 1 with DefaultTopologyCluster

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

the class DefaultTopology method buildTopologyClusters.

// Builds the topology clusters and returns the id-cluster bindings.
private ImmutableMap<ClusterId, TopologyCluster> buildTopologyClusters() {
    ImmutableMap.Builder<ClusterId, TopologyCluster> clusterBuilder = ImmutableMap.builder();
    SccResult<TopologyVertex, TopologyEdge> results = clusterResults.get();
    // Extract both vertexes and edges from the results; the lists form
    // pairs along the same index.
    List<Set<TopologyVertex>> clusterVertexes = results.clusterVertexes();
    List<Set<TopologyEdge>> clusterEdges = results.clusterEdges();
    // Scan over the lists and create a cluster from the results.
    for (int i = 0, n = results.clusterCount(); i < n; i++) {
        Set<TopologyVertex> vertexSet = clusterVertexes.get(i);
        Set<TopologyEdge> edgeSet = clusterEdges.get(i);
        ClusterId cid = ClusterId.clusterId(i);
        DefaultTopologyCluster cluster = new DefaultTopologyCluster(cid, vertexSet.size(), edgeSet.size(), findRoot(vertexSet));
        clusterBuilder.put(cid, cluster);
    }
    return clusterBuilder.build();
}
Also used : DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) TopologyVertex(org.onosproject.net.topology.TopologyVertex) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ClusterId(org.onosproject.net.topology.ClusterId) TopologyCluster(org.onosproject.net.topology.TopologyCluster) DefaultTopologyCluster(org.onosproject.net.topology.DefaultTopologyCluster) TopologyEdge(org.onosproject.net.topology.TopologyEdge) ImmutableMap(com.google.common.collect.ImmutableMap) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultTopologyCluster(org.onosproject.net.topology.DefaultTopologyCluster)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Set (java.util.Set)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 ClusterId (org.onosproject.net.topology.ClusterId)1 DefaultTopologyCluster (org.onosproject.net.topology.DefaultTopologyCluster)1 DefaultTopologyVertex (org.onosproject.net.topology.DefaultTopologyVertex)1 TopologyCluster (org.onosproject.net.topology.TopologyCluster)1 TopologyEdge (org.onosproject.net.topology.TopologyEdge)1 TopologyVertex (org.onosproject.net.topology.TopologyVertex)1