use of org.eclipse.elk.alg.layered.graph.LGraph in project elk by eclipse.
the class TestGraphCreator method getCrossWithManySelfLoopsGraph.
/**
* Cross formed graph, but each node has three extra self loop edges.
*
* <pre>
* * *
* \/
* /\
* * *
* .
* </pre>
*
* @return Graph of the form above.
*/
public LGraph getCrossWithManySelfLoopsGraph() {
LGraph selfLoopCrossGraph = getCrossFormedGraph();
for (Layer layer : selfLoopCrossGraph) {
for (LNode node : layer) {
selfLoopOn(node, PortSide.EAST);
selfLoopOn(node, PortSide.EAST);
selfLoopOn(node, PortSide.EAST);
selfLoopOn(node, PortSide.WEST);
selfLoopOn(node, PortSide.WEST);
selfLoopOn(node, PortSide.WEST);
}
}
return selfLoopCrossGraph;
}
use of org.eclipse.elk.alg.layered.graph.LGraph in project elk by eclipse.
the class SortByInputModelProcessorTest method preserveNodeAndEdgeOrder.
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Tests
@TestAfterProcessor(LayerSweepCrossingMinimizer.class)
public void preserveNodeAndEdgeOrder(final Object graph) {
LGraph lgraph = (LGraph) graph;
int layerIndex = 0;
for (Layer layer : lgraph) {
int nodeIndex = 0;
for (LNode node : layer.getNodes()) {
if (node.getType() == NodeType.NORMAL) {
assertEquals("A node is on an unexpected position.", "n_l" + layerIndex + "p" + nodeIndex, node.toString());
}
nodeIndex++;
}
layerIndex++;
}
}
use of org.eclipse.elk.alg.layered.graph.LGraph in project elk by eclipse.
the class LayerConstraintProcessorTest method noEmptyLayers.
/**
* All labels on ports and edges have an assigned {@link LabelSide}.
*/
@TestAfterProcessor(LayerConstraintPostprocessor.class)
public void noEmptyLayers(Object graph) {
LGraph lGraph = (LGraph) graph;
lGraph.getLayers().stream().forEach(layer -> assertTrue(!layer.getNodes().isEmpty()));
}
use of org.eclipse.elk.alg.layered.graph.LGraph in project elk by eclipse.
the class NodeMarginCalculatorTest method testNodeMargins.
private void testNodeMargins(final Object graph) {
LGraph lGraph = (LGraph) graph;
for (Layer layer : lGraph) {
for (LNode node : layer) {
assertTrue(node.getMargin() != null);
assertTrue(node.getMargin().top >= 0);
assertTrue(node.getMargin().right >= 0);
assertTrue(node.getMargin().bottom >= 0);
assertTrue(node.getMargin().left >= 0);
}
}
}
use of org.eclipse.elk.alg.layered.graph.LGraph in project elk by eclipse.
the class GreedySwitchProcessorTest method selfLoops.
@Test
public void selfLoops() {
Layer leftLayer = makeLayer(getGraph());
Layer rightLayer = makeLayer(getGraph());
LNode topLeft = addNodeToLayer(leftLayer);
LNode bottomLeft = addNodeToLayer(leftLayer);
LNode topRight = addNodeToLayer(rightLayer);
LNode bottomRight = addNodeToLayer(rightLayer);
LPort topLeftPort = addPortOnSide(topLeft, PortSide.EAST);
LPort bottomLeftPort = addPortOnSide(bottomLeft, PortSide.EAST);
setUpIds();
LGraph selfLoopCrossGraph = getGraph();
for (Layer layer : selfLoopCrossGraph) {
for (LNode node : layer) {
selfLoopOn(node, PortSide.EAST);
selfLoopOn(node, PortSide.EAST);
selfLoopOn(node, PortSide.EAST);
selfLoopOn(node, PortSide.WEST);
selfLoopOn(node, PortSide.WEST);
selfLoopOn(node, PortSide.WEST);
}
}
LPort topRightPort = addPortOnSide(topRight, PortSide.WEST);
LPort bottomRightPort = addPortOnSide(bottomRight, PortSide.WEST);
addEdgeBetweenPorts(topLeftPort, bottomRightPort);
addEdgeBetweenPorts(bottomLeftPort, topRightPort);
List<LNode> expectedOrderLayerOne;
List<LNode> expectedOrderLayerTwo;
if (greedyType == CrossMinType.ONE_SIDED_GREEDY_SWITCH) {
expectedOrderLayerOne = copyOfNodesInLayer(0);
expectedOrderLayerTwo = copyOfSwitchOrderOfNodesInLayer(0, 1, 1);
} else {
expectedOrderLayerOne = copyOfSwitchOrderOfNodesInLayer(0, 1, 0);
expectedOrderLayerTwo = copyOfNodesInLayer(1);
}
startGreedySwitcherWithCurrentType();
assertThat("Layer one", copyOfNodesInLayer(0), is(expectedOrderLayerOne));
assertThat("Layer two", copyOfNodesInLayer(1), is(expectedOrderLayerTwo));
}
Aggregations