Search in sources :

Example 41 with LNode

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();
}
Also used : LNode(org.eclipse.elk.alg.layered.graph.LNode) Layer(org.eclipse.elk.alg.layered.graph.Layer)

Example 42 with LNode

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();
}
Also used : LNode(org.eclipse.elk.alg.layered.graph.LNode) Layer(org.eclipse.elk.alg.layered.graph.Layer)

Example 43 with LNode

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;
}
Also used : LNode(org.eclipse.elk.alg.layered.graph.LNode)

Example 44 with LNode

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));
}
Also used : LPort(org.eclipse.elk.alg.layered.graph.LPort) LNode(org.eclipse.elk.alg.layered.graph.LNode) PortSide(org.eclipse.elk.core.options.PortSide) Test(org.junit.Test)

Example 45 with LNode

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));
}
Also used : LPort(org.eclipse.elk.alg.layered.graph.LPort) LNode(org.eclipse.elk.alg.layered.graph.LNode) Test(org.junit.Test)

Aggregations

LNode (org.eclipse.elk.alg.layered.graph.LNode)471 LPort (org.eclipse.elk.alg.layered.graph.LPort)189 Layer (org.eclipse.elk.alg.layered.graph.Layer)185 LEdge (org.eclipse.elk.alg.layered.graph.LEdge)110 LGraph (org.eclipse.elk.alg.layered.graph.LGraph)91 Test (org.junit.Test)85 KVector (org.eclipse.elk.core.math.KVector)38 PortSide (org.eclipse.elk.core.options.PortSide)28 List (java.util.List)23 LLabel (org.eclipse.elk.alg.layered.graph.LLabel)22 GraphInfoHolder (org.eclipse.elk.alg.layered.p3order.GraphInfoHolder)16 TestAfterProcessor (org.eclipse.elk.alg.test.framework.annotations.TestAfterProcessor)16 KVectorChain (org.eclipse.elk.core.math.KVectorChain)15 NodeType (org.eclipse.elk.alg.layered.graph.LNode.NodeType)14 ArrayList (java.util.ArrayList)13 InternalProperties (org.eclipse.elk.alg.layered.options.InternalProperties)13 LayeredOptions (org.eclipse.elk.alg.layered.options.LayeredOptions)13 PortConstraints (org.eclipse.elk.core.options.PortConstraints)13 Set (java.util.Set)12 CrossingsCounter (org.eclipse.elk.alg.layered.p3order.counting.CrossingsCounter)10