Search in sources :

Example 16 with CrossingsCounter

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

the class CrossingsCounterTest method countCrossingsBetweenPorts_givenWesternCrossings_OnlyCountsForGivenPorts.

/**
 * <pre>
 * *   /*
 * |  /
 * \ /____
 *  x/|  |
 * |/\|  |
 * *  |__|
 * </pre>
 */
@Test
public void countCrossingsBetweenPorts_givenWesternCrossings_OnlyCountsForGivenPorts() {
    LNode[] leftNodes = addNodesToLayer(2, makeLayer(getGraph()));
    LNode[] rightNodes = addNodesToLayer(2, makeLayer(getGraph()));
    eastWestEdgeFromTo(leftNodes[0], rightNodes[1]);
    eastWestEdgeFromTo(leftNodes[1], rightNodes[1]);
    eastWestEdgeFromTo(leftNodes[1], rightNodes[0]);
    counter = new CrossingsCounter(new int[getNumPorts(order())]);
    counter.initForCountingBetween(leftNodes, rightNodes);
    assertThat(counter.countCrossingsBetweenPortsInBothOrders(rightNodes[1].getPorts().get(1), rightNodes[1].getPorts().get(0)).getFirst(), 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 17 with CrossingsCounter

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

the class CrossingsCounterTest method countCrossingsBetweenPorts_GivenCrossingsOnEasternSide_.

/**
 * <pre>
 * ___
 * | |\/*
 * |_|/\*
 * </pre>
 */
@Test
public void countCrossingsBetweenPorts_GivenCrossingsOnEasternSide_() throws Exception {
    LNode[] leftNodes = addNodesToLayer(1, makeLayer());
    LNode[] rightNodes = addNodesToLayer(2, makeLayer());
    eastWestEdgeFromTo(leftNodes[0], rightNodes[1]);
    eastWestEdgeFromTo(leftNodes[0], rightNodes[0]);
    counter = new CrossingsCounter(new int[getNumPorts(order())]);
    counter.initForCountingBetween(leftNodes, rightNodes);
    assertThat(counter.countCrossingsBetweenPortsInBothOrders(leftNodes[0].getPorts().get(0), leftNodes[0].getPorts().get(1)).getFirst(), 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 18 with CrossingsCounter

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

the class NorthSouthEdgeAllCrossingsCounterTest method initCounterForLayerWithIndexAndCountInLayer.

private int initCounterForLayerWithIndexAndCountInLayer(final int layerIndex) {
    setUpIds();
    int numPorts = 0;
    for (Layer l : getGraph()) {
        for (LNode lNode : l) {
            numPorts += lNode.getPorts().size();
        }
    }
    CrossingsCounter counter = new CrossingsCounter(new int[numPorts]);
    return counter.countNorthSouthPortCrossingsInLayer(getGraph().toNodeArray()[layerIndex]);
}
Also used : LNode(org.eclipse.elk.alg.layered.graph.LNode) CrossingsCounter(org.eclipse.elk.alg.layered.p3order.counting.CrossingsCounter) Layer(org.eclipse.elk.alg.layered.graph.Layer)

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