Search in sources :

Example 1 with MultiMap

use of au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.util.MultiMap in project constellation by constellation-app.

the class InfomapGreedy method sortTree.

@Override
protected void sortTree(final NodeBase parent) {
    if (parent.getSubInfomap() != null) {
        parent.getSubInfomap().sortTree();
    }
    final MultiMap<Double, NodeBase> sortedModules = new MultiMap<>((d1, d2) -> (int) Math.signum(d2 - d1));
    if (DEBUG && parent.getChildDegree() > 0) {
        for (final NodeBase child : parent.getChildren()) {
            LOGGER.log(Level.INFO, "{0}", child.getId());
        }
    }
    for (final NodeBase child : parent.getChildren()) {
        sortTree(child);
        final double rank = getNode(child).getData().getFlow();
        sortedModules.put(rank, child);
    }
    parent.releaseChildren();
    int sortedIndex = 0;
    for (final Map.Entry<Double, NodeBase> entry : sortedModules.entrySet()) {
        parent.addChild(entry.getValue());
        entry.getValue().setIndex(sortedIndex);
        sortedIndex++;
    }
}
Also used : NodeBase(au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.NodeBase) MultiMap(au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.util.MultiMap) MultiMap(au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.util.MultiMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Aggregations

NodeBase (au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.NodeBase)1 MultiMap (au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.util.MultiMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1