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