use of org.eclipse.elk.alg.layered.graph.LGraph in project elk by eclipse.
the class BasicLayerAssignmentTest method testNoLayerlessNodes.
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Tests
@TestAfterProcessor(CoffmanGrahamLayerer.class)
@TestAfterProcessor(InteractiveLayerer.class)
@TestAfterProcessor(LongestPathLayerer.class)
@TestAfterProcessor(MinWidthLayerer.class)
@TestAfterProcessor(NetworkSimplexLayerer.class)
@TestAfterProcessor(StretchWidthLayerer.class)
public void testNoLayerlessNodes(final Object graph) {
LGraph lGraph = (LGraph) graph;
assertTrue(lGraph.getLayerlessNodes().isEmpty());
}
use of org.eclipse.elk.alg.layered.graph.LGraph in project elk by eclipse.
the class AbstractBarycenterPortDistributorTest method distributePortsOnSide_partlyCrossHierarchicalEdges_CrossHierarchyStaysOuterChanges.
/**
* <pre>
* ____
* | *+-- *
* | | \/
* | |\ /\
* | *+-x *
* |__| \
* -*
* </pre>
*/
// TODO this is a problem which currently cannot be solved by our algorithm :-(
@Ignore
public void distributePortsOnSide_partlyCrossHierarchicalEdges_CrossHierarchyStaysOuterChanges() {
LNode leftOuterNode = addNodeToLayer(makeLayer());
LNode[] rightNodes = addNodesToLayer(3, makeLayer());
LPort[] leftOuterPorts = addPortsOnSide(3, leftOuterNode, PortSide.EAST);
LGraph leftInnerGraph = nestedGraph(leftOuterNode);
LNode[] leftInnerNodes = addNodesToLayer(2, makeLayer(leftInnerGraph));
LNode[] leftInnerDummyNodes = new LNode[2];
Layer dummyLayer = makeLayer();
leftInnerDummyNodes[0] = addExternalPortDummyNodeToLayer(dummyLayer, leftOuterPorts[0]);
leftInnerDummyNodes[1] = addExternalPortDummyNodeToLayer(dummyLayer, leftOuterPorts[2]);
eastWestEdgeFromTo(leftInnerNodes[0], leftInnerDummyNodes[0]);
eastWestEdgeFromTo(leftInnerNodes[1], leftInnerDummyNodes[1]);
eastWestEdgeFromTo(leftOuterPorts[0], rightNodes[1]);
eastWestEdgeFromTo(leftOuterPorts[1], rightNodes[2]);
eastWestEdgeFromTo(leftOuterPorts[2], rightNodes[0]);
// leftOuterNode.setProperty(InternalProperties.HAS_HIERARCHICAL_AND_NORMAL_PORTS, true);
setPortOrderFixed(leftOuterNode);
setUpIds();
List<LPort> expectedOrder = Lists.newArrayList(switchOrderInArray(1, 2, leftOuterPorts));
distributePortsInCompleteGraph(8);
assertThat(leftOuterNode.getPorts(), is(expectedOrder));
}
use of org.eclipse.elk.alg.layered.graph.LGraph in project elk by eclipse.
the class LayerSweepCrossingMinimizerTest method inLayerCrossHierarchyCrossingsInLeftMostLayer.
/**
* <pre>
* *
* ||
* ----*
* | ____
* /-|-*|
* / | | |
*| --|-*| *
*| |__|
* \
* \
* \
* --*
* ||
* *
* </pre>
*/
@Test
public void inLayerCrossHierarchyCrossingsInLeftMostLayer() {
LNode[] nodes = addNodesToLayer(5, makeLayer());
addPortsOnSide(2, nodes[0], PortSide.WEST);
addNodeToLayer(makeLayer());
LPort[] topNodePorts = addPortsOnSide(2, nodes[0], PortSide.WEST);
LPort[] secondNodePorts = addPortsOnSide(3, nodes[1], PortSide.WEST);
addEdgeBetweenPorts(topNodePorts[0], secondNodePorts[2]);
addEdgeBetweenPorts(topNodePorts[1], secondNodePorts[1]);
LPort[] outerPorts = addPortsOnSide(2, nodes[2], PortSide.WEST);
LGraph inner = makeNestedTwoNodeGraphWithWesternPorts(nodes[2], outerPorts);
LPort[] fifthNodePorts = addPortsOnSide(3, nodes[3], PortSide.WEST);
LPort[] sixthNodePorts = addPortsOnSide(2, nodes[4], PortSide.WEST);
addEdgeBetweenPorts(fifthNodePorts[0], sixthNodePorts[1]);
addEdgeBetweenPorts(fifthNodePorts[1], sixthNodePorts[0]);
addEdgeBetweenPorts(outerPorts[0], fifthNodePorts[2]);
List<LPort> actualPortOrder = nodes[2].getPorts();
List<LPort> expectedPortOrder = getListCopyInIndexOrder(actualPortOrder, 1, 0);
List<LNode> actualNodeOrder = graph.getLayers().get(0).getNodes();
List<LNode> expectedNodeOrder = Lists.newArrayList(actualNodeOrder);
List<LNode> actualInnerNodeOrder = inner.getLayers().get(1).getNodes();
List<LNode> expectedInnerNodeOrder = getListCopyInIndexOrder(actualInnerNodeOrder, 1, 0);
graph.setProperty(LayeredOptions.CROSSING_MINIMIZATION_HIERARCHICAL_SWEEPINESS, 1.0);
setUpAndMinimizeCrossings();
assertThat(actualNodeOrder, is(expectedNodeOrder));
assertThat(actualPortOrder, is(expectedPortOrder));
assertThat(actualInnerNodeOrder, is(expectedInnerNodeOrder));
}
use of org.eclipse.elk.alg.layered.graph.LGraph in project elk by eclipse.
the class LayerSweepCrossingMinimizerTest method recursiveLayout_givenCrossInFirstLevelCompoundNode_sortsPortsAccordingly.
/**
* <pre>
* _______
* |* *-|--*
* | \/ |
* | /\ |
* |* *-|--*
* |*--* |
* |*--* |
* |*--* |
* |*--* |
* |*--* |
* |*--* |
* |-----|
* </pre>
*/
@Test
public void recursiveLayout_givenCrossInFirstLevelCompoundNode_sortsPortsAccordingly() {
// parent graph
LNode leftOuterNode = addNodeToLayer(makeLayer(getGraph()));
LNode[] rightNodes = addNodesToLayer(2, makeLayer(getGraph()));
LPort[] leftOuterPorts = addPortsOnSide(2, leftOuterNode, PortSide.EAST);
eastWestEdgeFromTo(leftOuterPorts[0], rightNodes[0]);
eastWestEdgeFromTo(leftOuterPorts[1], rightNodes[1]);
// child graph
LGraph leftInnerGraph = nestedGraph(leftOuterNode);
LNode[] leftInnerNodesLeft = addNodesToLayer(9, makeLayer(leftInnerGraph));
LNode[] leftInnerNodesRight = addNodesToLayer(9, makeLayer(leftInnerGraph));
LNode[] leftInnerDummyNodes = addExternalPortDummiesToLayer(makeLayer(leftInnerGraph), leftOuterPorts);
eastWestEdgeFromTo(leftInnerNodesRight[0], leftInnerDummyNodes[0]);
eastWestEdgeFromTo(leftInnerNodesRight[1], leftInnerDummyNodes[1]);
eastWestEdgeFromTo(leftInnerNodesLeft[0], leftInnerNodesRight[1]);
eastWestEdgeFromTo(leftInnerNodesLeft[1], leftInnerNodesRight[0]);
for (int i = 2; i < leftInnerNodesLeft.length; i++) {
eastWestEdgeFromTo(leftInnerNodesLeft[i], leftInnerNodesRight[i]);
}
List<LNode> expectedOrderRight = copyOfSwitchOrderOfNodesInLayer(0, 1, 1);
List<LPort> expectedPortOrderLeft = copyPortsInIndexOrder(leftOuterNode, 1, 0);
setUpAndMinimizeCrossings();
if (crossMinType == CrossMinType.BARYCENTER) {
assertThat(leftOuterNode.getPorts(), is(expectedPortOrderLeft));
assertThat(getGraph().getLayers().get(1).getNodes(), is(expectedOrderRight));
}
}
use of org.eclipse.elk.alg.layered.graph.LGraph in project elk by eclipse.
the class LayerSweepCrossingMinimizerTest method givenSimpleHierarchicalCross_ShouldResultInNoCrossing.
/**
* <pre>
* ____ ____
* |*-+ +-*|
* | |\/| |
* |*-+/\+-*|
* |--| |--|
* </pre>
*/
@Test
public void givenSimpleHierarchicalCross_ShouldResultInNoCrossing() {
LNode leftOuterNode = addNodeToLayer(makeLayer(getGraph()));
LNode rightOuterNode = addNodeToLayer(makeLayer(getGraph()));
LPort[] leftOuterPorts = addPortsOnSide(2, leftOuterNode, PortSide.EAST);
LPort[] rightOuterPorts = addPortsOnSide(2, rightOuterNode, PortSide.WEST);
addEdgeBetweenPorts(leftOuterPorts[0], rightOuterPorts[0]);
addEdgeBetweenPorts(leftOuterPorts[1], rightOuterPorts[1]);
makeNestedTwoNodeGraphWithEasternPorts(leftOuterNode, leftOuterPorts);
LGraph rightInnerGraph = makeNestedTwoNodeGraphWithWesternPorts(rightOuterNode, rightOuterPorts);
List<LNode> expectedExternalDummyOrderRight = switchOrderOfNodesInLayer(0, 1, rightInnerGraph.getLayers().get(0));
List<LNode> expectedNormalNodeOrderRight = switchOrderOfNodesInLayer(0, 1, rightInnerGraph.getLayers().get(1));
List<LPort> expectedOrderOfPortsRight = Lists.newArrayList(rightOuterPorts[1], rightOuterPorts[0]);
setOnAllGraphs(LayeredOptions.CROSSING_MINIMIZATION_HIERARCHICAL_SWEEPINESS, 0.1, graph);
setUpAndMinimizeCrossings();
List<LNode> actualExternalDummyOrderRight = rightInnerGraph.getLayers().get(0).getNodes();
assertThat(actualExternalDummyOrderRight, is(expectedExternalDummyOrderRight));
assertThat(rightOuterNode.getPorts(), is(expectedOrderOfPortsRight));
List<LNode> actualNormalOrderRight = rightInnerGraph.getLayers().get(1).getNodes();
assertThat(actualNormalOrderRight, is(expectedNormalNodeOrderRight));
}
Aggregations