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();
}
Aggregations