Search in sources :

Example 46 with LNode

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

Example 47 with LNode

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

Example 48 with LNode

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

Example 49 with LNode

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

Example 50 with LNode

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

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