use of org.eclipse.elk.alg.layered.graph.LNode in project elk by eclipse.
the class InLayerEdgeTestGraphCreator method getInLayerEdgesDownwardGraphNoFixedOrder.
/**
* <pre>
*
* --*
* | ____
* |/| |
* /\| |
* | | |
* *-+-|__|
* |
* \
* *
* .
* </pre>
*
* Port order not fixed.
*
* @return Graph of the form above.
*/
public LGraph getInLayerEdgesDownwardGraphNoFixedOrder() {
Layer[] layers = makeLayers(2);
LNode leftNode = addNodeToLayer(layers[0]);
LNode[] rightNodes = addNodesToLayer(3, layers[1]);
eastWestEdgeFromTo(leftNode, rightNodes[1]);
addInLayerEdge(rightNodes[0], rightNodes[1], PortSide.WEST);
addInLayerEdge(rightNodes[1], rightNodes[2], PortSide.WEST);
return getGraph();
}
use of org.eclipse.elk.alg.layered.graph.LNode in project elk by eclipse.
the class InLayerEdgeTestGraphCreator method getInLayerEdgesGraphWithCrossingsToBetweenLayerEdgeWithFixedPortOrder.
// CHECKSTYLEOFF MagicNumber
/**
* <pre>
* ____ _____
* | |---| |
* | |---| |
* | | | |
* | | /| |
* |__|--+|___|
* |
* \
* *
* .
* </pre>
*
* @return Graph of the form above.
*/
public LGraph getInLayerEdgesGraphWithCrossingsToBetweenLayerEdgeWithFixedPortOrder() {
Layer[] layers = makeLayers(2);
LNode leftNode = addNodeToLayer(layers[0]);
LNode[] rightNodes = addNodesToLayer(2, layers[1]);
setPortOrderFixed(rightNodes[0]);
// since we expect bottom up ordering of western ports, the order of
// adding edges is
// important
eastWestEdgeFromTo(leftNode, rightNodes[0]);
addInLayerEdge(rightNodes[0], rightNodes[1], PortSide.WEST);
eastWestEdgeFromTo(leftNode, rightNodes[0]);
eastWestEdgeFromTo(leftNode, rightNodes[0]);
return getGraph();
}
use of org.eclipse.elk.alg.layered.graph.LNode in project elk by eclipse.
the class InLayerEdgeTwoNodeCrossingCounterTest method switchOrderAndNotifyCounter.
private void switchOrderAndNotifyCounter(final int indexOne, final int indexTwo) {
leftCounter.switchNodes(nodeOrder[indexOne], nodeOrder[indexTwo], PortSide.WEST);
rightCounter.switchNodes(nodeOrder[indexOne], nodeOrder[indexTwo], PortSide.EAST);
LNode one = nodeOrder[indexOne];
nodeOrder[indexOne] = nodeOrder[indexTwo];
nodeOrder[indexTwo] = one;
}
use of org.eclipse.elk.alg.layered.graph.LNode in project elk by eclipse.
the class InLayerEdgeTwoNodeCrossingCounterTest method multipleEdgesIntoOnePort_ShouldNotCauseCrossing.
/**
* <pre>
* *------
* *---\ |
* ___ | |
* | |--/
* |_|
* </pre>
*/
@Test
public void multipleEdgesIntoOnePort_ShouldNotCauseCrossing() {
LNode[] nodes = addNodesToLayer(3, makeLayer(getGraph()));
final PortSide portSide = PortSide.EAST;
LPort portOne = addPortOnSide(nodes[0], portSide);
LPort portTwo = addPortOnSide(nodes[1], portSide);
LPort portThree = addPortOnSide(nodes[2], portSide);
addEdgeBetweenPorts(portOne, portThree);
addEdgeBetweenPorts(portTwo, portThree);
countCrossingsInLayerForUpperNodeLowerNode(0, 0, 1);
assertThat("upperLowerCrossings", upperLowerCrossings, is(0));
assertThat("lowerUpperCrossings", lowerUpperCrossings, is(0));
}
use of org.eclipse.elk.alg.layered.graph.LNode in project elk by eclipse.
the class NorthSouthEdgeNeighbouringNodeCrossingsCounterTest method multipleEdgesInBothDirectionsNSNode.
/**
* <pre>
* *===.--*
* |
* *-.====*
* | |
* _|_|_
* | |
* |___|
* </pre>
*/
@Test
public void multipleEdgesInBothDirectionsNSNode() {
LNode[] leftLayer = addNodesToLayer(2, makeLayer());
LNode[] middleLayer = addNodesToLayer(3, makeLayer());
LNode[] rightLayer = addNodesToLayer(2, makeLayer());
setFixedOrderConstraint(middleLayer[2]);
addNorthSouthEdge(PortSide.NORTH, middleLayer[2], middleLayer[1], leftLayer[1], true);
LPort normalNodePort = addPortOnSide(rightLayer[1], PortSide.WEST);
LPort dummyNodePort = addPortOnSide(middleLayer[1], PortSide.EAST);
addEdgeBetweenPorts(dummyNodePort, normalNodePort);
addEdgeBetweenPorts(dummyNodePort, normalNodePort);
LPort originPort = middleLayer[2].getPorts().get(0);
dummyNodePort.setProperty(InternalProperties.ORIGIN, originPort);
addNorthSouthEdge(PortSide.NORTH, middleLayer[2], middleLayer[0], rightLayer[0], false);
normalNodePort = addPortOnSide(rightLayer[0], PortSide.EAST);
dummyNodePort = addPortOnSide(middleLayer[0], PortSide.WEST);
addEdgeBetweenPorts(dummyNodePort, normalNodePort);
addEdgeBetweenPorts(dummyNodePort, normalNodePort);
originPort = middleLayer[2].getPorts().get(1);
dummyNodePort.setProperty(InternalProperties.ORIGIN, originPort);
countCrossingsInLayerBetweenNodes(1, 0, 1);
assertThat(counter.getUpperLowerCrossings(), is(2));
// Note that the three other crossings which result from this switch are
// counted by a
// different crossings counter.
assertThat(counter.getLowerUpperCrossings(), is(2));
}
Aggregations