use of org.eclipse.elk.alg.layered.graph.LNode in project elk by eclipse.
the class NorthSouthEdgeNeighbouringNodeCrossingsCounterTest method givenPolylineRoutingWhenMoreThanOneEdgeIntoNSNode_countsTheseToo.
/**
* <pre>
*
* *----
* /+--*
* --+--*
* | |
* _|_|_
* | |
* |___|
* .
* </pre>
*/
@Test
public void givenPolylineRoutingWhenMoreThanOneEdgeIntoNSNode_countsTheseToo() {
LNode leftNode = addNodeToLayer(makeLayer(getGraph()));
LNode[] middleNodes = addNodesToLayer(3, makeLayer(getGraph()));
LNode[] rightNodes = addNodesToLayer(2, makeLayer(getGraph()));
setFixedOrderConstraint(middleNodes[2]);
// ports are added in clockwise fashion!
addNorthSouthEdge(PortSide.NORTH, middleNodes[2], middleNodes[1], rightNodes[0], false);
addNorthSouthEdge(PortSide.NORTH, middleNodes[2], middleNodes[0], leftNode, true);
// second edge on middle node
LPort middleNodePort = middleNodes[1].getPorts().get(0);
eastWestEdgeFromTo(middleNodePort, rightNodes[1]);
getGraph().setProperty(LayeredOptions.EDGE_ROUTING, EdgeRouting.POLYLINE);
countCrossingsInLayerBetweenNodes(1, 0, 1);
assertThat(counter.getUpperLowerCrossings(), is(2));
assertThat(counter.getLowerUpperCrossings(), is(1));
}
use of org.eclipse.elk.alg.layered.graph.LNode in project elk by eclipse.
the class NorthSouthEdgeNeighbouringNodeCrossingsCounterTest method edgesInBothDirections.
/**
* <pre>
* *---.--*
* |
* *-.-+--*
* | |
* _|_|_
* | |
* |___|
* </pre>
*/
@Test
public void edgesInBothDirections() {
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);
LPort originPort = middleLayer[2].getPorts().get(0);
dummyNodePort.setProperty(InternalProperties.ORIGIN, originPort);
addNorthSouthEdge(PortSide.NORTH, middleLayer[2], middleLayer[0], leftLayer[0], true);
normalNodePort = addPortOnSide(rightLayer[0], PortSide.WEST);
dummyNodePort = addPortOnSide(middleLayer[0], PortSide.EAST);
addEdgeBetweenPorts(dummyNodePort, normalNodePort);
originPort = middleLayer[2].getPorts().get(1);
dummyNodePort.setProperty(InternalProperties.ORIGIN, originPort);
countCrossingsInLayerBetweenNodes(1, 0, 1);
assertThat(counter.getUpperLowerCrossings(), is(1));
// Note that the two other crossings which result from this switch are
// counted by a
// different crossings counter.
assertThat(counter.getLowerUpperCrossings(), is(1));
}
use of org.eclipse.elk.alg.layered.graph.LNode in project elk by eclipse.
the class NorthSouthEdgeNeighbouringNodeCrossingsCounterTest method givenMultipleEdgesInOneNSNodeCountsCrossings.
/**
* <pre>
* .--*
* |
* *-.-+--*
* | |
* _|_|_
* | |
* |___|
* </pre>
*/
@Test
public void givenMultipleEdgesInOneNSNodeCountsCrossings() {
LNode leftNode = addNodeToLayer(makeLayer());
LNode[] middleLayer = addNodesToLayer(3, makeLayer());
LNode[] rightLayer = addNodesToLayer(2, makeLayer());
setFixedOrderConstraint(middleLayer[2]);
addNorthSouthEdge(PortSide.NORTH, middleLayer[2], middleLayer[1], leftNode, true);
LPort normalNodePort = addPortOnSide(rightLayer[1], PortSide.WEST);
LPort dummyNodePort = addPortOnSide(middleLayer[1], PortSide.EAST);
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);
countCrossingsInLayerBetweenNodes(1, 0, 1);
assertThat(counter.getUpperLowerCrossings(), is(1));
assertThat(counter.getLowerUpperCrossings(), is(0));
}
use of org.eclipse.elk.alg.layered.graph.LNode in project elk by eclipse.
the class NorthSouthEdgeTestGraphCreator method getNorthernNorthSouthDummyEdgeCrossingGraph.
/**
* <pre>
* *---*
* |
* *-+*--*
* |
* *
* </pre>
*
* .
*
* @return Graph of the form above.
*/
public LGraph getNorthernNorthSouthDummyEdgeCrossingGraph() {
LNode leftNode = addNodeToLayer(makeLayer(getGraph()));
LNode[] middleNodes = addNodesToLayer(3, makeLayer(getGraph()));
LNode[] rightNodes = addNodesToLayer(2, makeLayer(getGraph()));
eastWestEdgeFromTo(leftNode, middleNodes[1]);
eastWestEdgeFromTo(middleNodes[1], rightNodes[1]);
setAsLongEdgeDummy(middleNodes[1]);
addNorthSouthEdge(PortSide.NORTH, middleNodes[2], middleNodes[0], rightNodes[0], true);
return getGraph();
}
use of org.eclipse.elk.alg.layered.graph.LNode in project elk by eclipse.
the class NorthSouthEdgeTestGraphCreator method getSouthernNorthSouthDummyEdgeCrossingGraph.
/**
* <pre>
* *
* |
* *-+*--*
* |
* *---*
* </pre>
*
* .
*
* @return Graph of the form above.
*/
public LGraph getSouthernNorthSouthDummyEdgeCrossingGraph() {
LNode leftNode = addNodeToLayer(makeLayer(getGraph()));
LNode[] middleNodes = addNodesToLayer(3, makeLayer(getGraph()));
LNode[] rightNodes = addNodesToLayer(2, makeLayer(getGraph()));
eastWestEdgeFromTo(leftNode, middleNodes[1]);
eastWestEdgeFromTo(middleNodes[1], rightNodes[0]);
setAsLongEdgeDummy(middleNodes[1]);
addNorthSouthEdge(PortSide.SOUTH, middleNodes[0], middleNodes[2], rightNodes[1], true);
return getGraph();
}
Aggregations