Search in sources :

Example 1 with CrossingsCounter

use of org.eclipse.elk.alg.layered.p3order.counting.CrossingsCounter in project elk by eclipse.

the class InLayerEdgeTwoNodeCrossingCounterTest method initCrossingCounterForLayerIndex.

/**
 * Initializes Crossing counter, sets nodeOrder with the nodes from the
 * layer being considered and numbers its in ascending form as required by
 * the counter.
 *
 * @param layerIndex
 */
private void initCrossingCounterForLayerIndex(final int layerIndex) {
    LNode[][] currentOrder = getGraph().toNodeArray();
    nodeOrder = currentOrder[layerIndex];
    numberIdsAscendinglyIn(nodeOrder);
    leftCounter = new CrossingsCounter(new int[getNPorts(currentOrder)]);
    rightCounter = new CrossingsCounter(new int[getNPorts(currentOrder)]);
    leftCounter.initPortPositionsForInLayerCrossings(nodeOrder, PortSide.WEST);
    rightCounter.initPortPositionsForInLayerCrossings(nodeOrder, PortSide.EAST);
}
Also used : CrossingsCounter(org.eclipse.elk.alg.layered.p3order.counting.CrossingsCounter)

Example 2 with CrossingsCounter

use of org.eclipse.elk.alg.layered.p3order.counting.CrossingsCounter in project elk by eclipse.

the class SwitchDecider method initParentCrossingsCounters.

private void initParentCrossingsCounters(final int freeLayerIndex, final int length) {
    GraphInfoHolder parentGraphData = graphData.parentGraphData();
    LNode[][] parentNodeOrder = parentGraphData.currentNodeOrder();
    int[] portPos = parentGraphData.portPositions();
    parentCrossCounter = new CrossingsCounter(portPos);
    int parentNodeLayerPos = graphData.parent().getLayer().id;
    LNode[] leftLayer = parentNodeLayerPos > 0 ? parentNodeOrder[parentNodeLayerPos - 1] : new LNode[0];
    LNode[] middleLayer = parentNodeOrder[parentNodeLayerPos];
    LNode[] rightLayer = parentNodeLayerPos < parentNodeOrder.length - 1 ? parentNodeOrder[parentNodeLayerPos + 1] : new LNode[0];
    boolean rightMostLayer = freeLayerIndex == length - 1;
    if (rightMostLayer) {
        parentCrossCounter.initForCountingBetween(middleLayer, rightLayer);
    } else {
        parentCrossCounter.initForCountingBetween(leftLayer, middleLayer);
    }
}
Also used : CrossingsCounter(org.eclipse.elk.alg.layered.p3order.counting.CrossingsCounter) LNode(org.eclipse.elk.alg.layered.graph.LNode) GraphInfoHolder(org.eclipse.elk.alg.layered.p3order.GraphInfoHolder)

Example 3 with CrossingsCounter

use of org.eclipse.elk.alg.layered.p3order.counting.CrossingsCounter in project elk by eclipse.

the class CrossingsCounterTest method countCrossingsBetweenLayers_fixedPortOrderCrossingOnTwoNodes.

/**
 * <pre>
 * ___  ___
 * | |\/| |
 * |_|/\|_|
 * </pre>
 */
@Test
public void countCrossingsBetweenLayers_fixedPortOrderCrossingOnTwoNodes() {
    LNode left = addNodeToLayer(makeLayer(getGraph()));
    LNode right = addNodeToLayer(makeLayer(getGraph()));
    eastWestEdgeFromTo(left, right);
    eastWestEdgeFromTo(left, right);
    counter = new CrossingsCounter(new int[getNumPorts(order())]);
    assertThat(counter.countCrossingsBetweenLayers(order()[0], order()[1]), is(1));
}
Also used : LNode(org.eclipse.elk.alg.layered.graph.LNode) CrossingsCounter(org.eclipse.elk.alg.layered.p3order.counting.CrossingsCounter) Test(org.junit.Test)

Example 4 with CrossingsCounter

use of org.eclipse.elk.alg.layered.p3order.counting.CrossingsCounter in project elk by eclipse.

the class CrossingsCounterTest method countCrossingsBetweenLayers_crossWithExtraEdgeInBetween.

@Test
public void countCrossingsBetweenLayers_crossWithExtraEdgeInBetween() {
    getCrossWithExtraEdgeInBetweenGraph();
    counter = new CrossingsCounter(new int[getNumPorts(order())]);
    assertThat(counter.countCrossingsBetweenLayers(order()[0], order()[1]), is(3));
}
Also used : CrossingsCounter(org.eclipse.elk.alg.layered.p3order.counting.CrossingsCounter) Test(org.junit.Test)

Example 5 with CrossingsCounter

use of org.eclipse.elk.alg.layered.p3order.counting.CrossingsCounter in project elk by eclipse.

the class CrossingsCounterTest method countCrossingsBetweenLayers_crossFormed.

@Test
public void countCrossingsBetweenLayers_crossFormed() {
    getCrossFormedGraph();
    counter = new CrossingsCounter(new int[getNumPorts(order())]);
    assertThat(counter.countCrossingsBetweenLayers(order()[0], order()[1]), is(1));
}
Also used : CrossingsCounter(org.eclipse.elk.alg.layered.p3order.counting.CrossingsCounter) Test(org.junit.Test)

Aggregations

CrossingsCounter (org.eclipse.elk.alg.layered.p3order.counting.CrossingsCounter)18 Test (org.junit.Test)13 LNode (org.eclipse.elk.alg.layered.graph.LNode)10 LPort (org.eclipse.elk.alg.layered.graph.LPort)4 Layer (org.eclipse.elk.alg.layered.graph.Layer)4 GraphInfoHolder (org.eclipse.elk.alg.layered.p3order.GraphInfoHolder)3 Date (java.util.Date)1 BetweenLayerEdgeTwoNodeCrossingsCounter (org.eclipse.elk.alg.layered.intermediate.greedyswitch.BetweenLayerEdgeTwoNodeCrossingsCounter)1 Ignore (org.junit.Ignore)1