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