Search in sources :

Example 1 with Tree

use of org.eclipse.elk.alg.common.Tree in project elk by eclipse.

the class MaxSTPhase method process.

@Override
public void process(final Graph graph, final IElkProgressMonitor progressMonitor) {
    progressMonitor.begin("Maximum spanning tree construction", 1);
    // inverted cost function
    ICostFunction invertedCF = e -> {
        return -graph.costFunction.cost(e);
    };
    KVector root;
    if (graph.preferredRoot != null) {
        root = graph.preferredRoot.vertex;
    } else {
        root = graph.vertices.get(0).vertex;
    }
    Tree<KVector> tree;
    if (graph.getProperty(InternalProperties.DEBUG_SVG)) {
        tree = NaiveMinST.createSpanningTree(graph.tEdges, root, invertedCF, ElkUtil.debugFolderPath("spore") + "20minst");
    } else {
        tree = NaiveMinST.createSpanningTree(graph.tEdges, root, invertedCF);
    }
    // convert result to a Tree that can be used in the execution phase
    convert(tree, graph);
    progressMonitor.done();
}
Also used : ICostFunction(org.eclipse.elk.alg.common.ICostFunction) ElkUtil(org.eclipse.elk.core.util.ElkUtil) NaiveMinST(org.eclipse.elk.alg.common.NaiveMinST) KVector(org.eclipse.elk.core.math.KVector) IElkProgressMonitor(org.eclipse.elk.core.util.IElkProgressMonitor) ICostFunction(org.eclipse.elk.alg.common.ICostFunction) Tree(org.eclipse.elk.alg.common.Tree) Graph(org.eclipse.elk.alg.spore.graph.Graph) InternalProperties(org.eclipse.elk.alg.common.spore.InternalProperties) KVector(org.eclipse.elk.core.math.KVector)

Aggregations

ICostFunction (org.eclipse.elk.alg.common.ICostFunction)1 NaiveMinST (org.eclipse.elk.alg.common.NaiveMinST)1 Tree (org.eclipse.elk.alg.common.Tree)1 InternalProperties (org.eclipse.elk.alg.common.spore.InternalProperties)1 Graph (org.eclipse.elk.alg.spore.graph.Graph)1 KVector (org.eclipse.elk.core.math.KVector)1 ElkUtil (org.eclipse.elk.core.util.ElkUtil)1 IElkProgressMonitor (org.eclipse.elk.core.util.IElkProgressMonitor)1