Search in sources :

Example 76 with LEdge

use of org.eclipse.elk.alg.layered.graph.LEdge in project elk by eclipse.

the class PartitionMidprocessor method connectNodes.

/**
 * Connects all nodes from the first collection to all nodes from the second collection.
 */
private void connectNodes(final Collection<LNode> firstPartition, final Collection<LNode> secondPartition) {
    for (LNode node : firstPartition) {
        LPort sourcePort = new LPort();
        sourcePort.setNode(node);
        sourcePort.setSide(PortSide.EAST);
        sourcePort.setProperty(InternalProperties.PARTITION_DUMMY, true);
        for (LNode otherNode : secondPartition) {
            LPort targetPort = new LPort();
            targetPort.setNode(otherNode);
            targetPort.setSide(PortSide.WEST);
            targetPort.setProperty(InternalProperties.PARTITION_DUMMY, true);
            LEdge edge = new LEdge();
            edge.setProperty(InternalProperties.PARTITION_DUMMY, true);
            edge.setSource(sourcePort);
            edge.setTarget(targetPort);
        }
    }
}
Also used : LEdge(org.eclipse.elk.alg.layered.graph.LEdge) LPort(org.eclipse.elk.alg.layered.graph.LPort) LNode(org.eclipse.elk.alg.layered.graph.LNode)

Example 77 with LEdge

use of org.eclipse.elk.alg.layered.graph.LEdge in project elk by eclipse.

the class BasicCycleBreakerTest method dfs.

private void dfs(final LNode node) {
    if (node.id != DFS_UNVISITED) {
        return;
    }
    node.id = nextDFSNumber++;
    putOnCurrentStack(node);
    for (LEdge lEdge : node.getOutgoingEdges()) {
        LNode target = lEdge.getTarget().getNode();
        if (target.id == DFS_UNVISITED) {
            dfs(target);
        } else if (isOnCurrentStack(target)) {
            fail("Cycle detected!");
        }
    }
    removeFromCurrentStack(node);
}
Also used : LEdge(org.eclipse.elk.alg.layered.graph.LEdge) LNode(org.eclipse.elk.alg.layered.graph.LNode)

Example 78 with LEdge

use of org.eclipse.elk.alg.layered.graph.LEdge in project elk by eclipse.

the class BasicLayerAssignmentTest method testEdgesPointTowardsNextLayers.

@TestAfterProcessor(CoffmanGrahamLayerer.class)
@TestAfterProcessor(InteractiveLayerer.class)
@TestAfterProcessor(LongestPathLayerer.class)
@TestAfterProcessor(MinWidthLayerer.class)
@TestAfterProcessor(NetworkSimplexLayerer.class)
@TestAfterProcessor(StretchWidthLayerer.class)
public void testEdgesPointTowardsNextLayers(final Object graph) {
    LGraph lGraph = (LGraph) graph;
    // Assign increasing IDs to the layers
    int nextLayerId = 0;
    for (Layer layer : lGraph) {
        layer.id = nextLayerId++;
    }
    for (Layer layer : lGraph) {
        for (LNode node : layer) {
            int nodeLayerId = node.getLayer().id;
            for (LEdge edge : node.getOutgoingEdges()) {
                assertTrue(nodeLayerId < edge.getTarget().getNode().getLayer().id);
            }
        }
    }
}
Also used : LEdge(org.eclipse.elk.alg.layered.graph.LEdge) LNode(org.eclipse.elk.alg.layered.graph.LNode) LGraph(org.eclipse.elk.alg.layered.graph.LGraph) Layer(org.eclipse.elk.alg.layered.graph.Layer) TestAfterProcessor(org.eclipse.elk.alg.test.framework.annotations.TestAfterProcessor)

Example 79 with LEdge

use of org.eclipse.elk.alg.layered.graph.LEdge in project elk by eclipse.

the class WhiteBoxTest method testProperLayering.

/**
 * Checks that the layering is proper.
 */
@TestAfterProcessor(NetworkSimplexLayerer.class)
@FailIfNotExecuted
public void testProperLayering(final Object graph) {
    LGraph lGraph = (LGraph) graph;
    for (Layer layer : lGraph) {
        int sourceLayerIndex = layer.getIndex();
        for (LNode lnode : layer) {
            for (LEdge ledge : lnode.getOutgoingEdges()) {
                int targetLayerIndex = ledge.getTarget().getNode().getLayer().getIndex();
                assertTrue("Edge points leftwards!", sourceLayerIndex <= targetLayerIndex);
            }
        }
    }
}
Also used : LEdge(org.eclipse.elk.alg.layered.graph.LEdge) LNode(org.eclipse.elk.alg.layered.graph.LNode) LGraph(org.eclipse.elk.alg.layered.graph.LGraph) Layer(org.eclipse.elk.alg.layered.graph.Layer) TestAfterProcessor(org.eclipse.elk.alg.test.framework.annotations.TestAfterProcessor) FailIfNotExecuted(org.eclipse.elk.alg.test.framework.annotations.FailIfNotExecuted)

Example 80 with LEdge

use of org.eclipse.elk.alg.layered.graph.LEdge in project elk by eclipse.

the class EndLabelPreprocessor method gatherLabels.

/**
 * Puts all relevant end labels of edges connected to the given port into the given list. Returns the maximum edge
 * thickness of any incident edge or {@link #NO_INCIDENT_EDGE_THICKNESS} if there is no incident edge.
 */
private static double gatherLabels(final LPort port, final List<LLabel> targetList) {
    double maxEdgeThickness = -1;
    List<LLabel> labels = new LinkedList<>();
    for (LEdge incidentEdge : port.getConnectedEdges()) {
        maxEdgeThickness = Math.max(maxEdgeThickness, incidentEdge.getProperty(LayeredOptions.EDGE_THICKNESS));
        if (incidentEdge.getSource() == port) {
            // It's an outgoing edge; all tail labels belong to this port
            incidentEdge.getLabels().stream().filter(label -> label.getProperty(LayeredOptions.EDGE_LABELS_PLACEMENT) == EdgeLabelPlacement.TAIL).forEach(label -> labels.add(label));
        } else {
            // It's an incoming edge; all head labels belong to this port
            incidentEdge.getLabels().stream().filter(label -> label.getProperty(LayeredOptions.EDGE_LABELS_PLACEMENT) == EdgeLabelPlacement.HEAD).forEach(label -> labels.add(label));
        }
        // Remember the edge each label came from
        for (LLabel label : labels) {
            if (!label.hasProperty(InternalProperties.END_LABEL_EDGE)) {
                label.setProperty(InternalProperties.END_LABEL_EDGE, incidentEdge);
            }
        }
        targetList.addAll(labels);
        labels.clear();
    }
    return maxEdgeThickness;
}
Also used : LLabel(org.eclipse.elk.alg.layered.graph.LLabel) PortSide(org.eclipse.elk.core.options.PortSide) RectangleStripOverlapRemover(org.eclipse.elk.alg.common.overlaps.RectangleStripOverlapRemover) IElkProgressMonitor(org.eclipse.elk.core.util.IElkProgressMonitor) HorizontalLabelAlignment(org.eclipse.elk.alg.common.nodespacing.cellsystem.HorizontalLabelAlignment) HashMap(java.util.HashMap) LEdge(org.eclipse.elk.alg.layered.graph.LEdge) ILayoutProcessor(org.eclipse.elk.core.alg.ILayoutProcessor) LayeredOptions(org.eclipse.elk.alg.layered.options.LayeredOptions) OverlapRemovalDirection(org.eclipse.elk.alg.common.overlaps.RectangleStripOverlapRemover.OverlapRemovalDirection) ElkRectangle(org.eclipse.elk.core.math.ElkRectangle) VerticalLabelAlignment(org.eclipse.elk.alg.common.nodespacing.cellsystem.VerticalLabelAlignment) Lists(com.google.common.collect.Lists) InternalProperties(org.eclipse.elk.alg.layered.options.InternalProperties) LabelSide(org.eclipse.elk.core.options.LabelSide) Map(java.util.Map) LGraphAdapters(org.eclipse.elk.alg.layered.graph.LGraphAdapters) LinkedList(java.util.LinkedList) EnumSet(java.util.EnumSet) KVector(org.eclipse.elk.core.math.KVector) LMargin(org.eclipse.elk.alg.layered.graph.LMargin) LabelCell(org.eclipse.elk.alg.common.nodespacing.cellsystem.LabelCell) List(java.util.List) LGraph(org.eclipse.elk.alg.layered.graph.LGraph) LPort(org.eclipse.elk.alg.layered.graph.LPort) EdgeLabelPlacement(org.eclipse.elk.core.options.EdgeLabelPlacement) LNode(org.eclipse.elk.alg.layered.graph.LNode) LLabel(org.eclipse.elk.alg.layered.graph.LLabel) LEdge(org.eclipse.elk.alg.layered.graph.LEdge) LinkedList(java.util.LinkedList)

Aggregations

LEdge (org.eclipse.elk.alg.layered.graph.LEdge)148 LNode (org.eclipse.elk.alg.layered.graph.LNode)107 LPort (org.eclipse.elk.alg.layered.graph.LPort)80 Layer (org.eclipse.elk.alg.layered.graph.Layer)41 KVector (org.eclipse.elk.core.math.KVector)34 KVectorChain (org.eclipse.elk.core.math.KVectorChain)20 LLabel (org.eclipse.elk.alg.layered.graph.LLabel)17 LGraph (org.eclipse.elk.alg.layered.graph.LGraph)16 PortSide (org.eclipse.elk.core.options.PortSide)11 ArrayList (java.util.ArrayList)9 List (java.util.List)9 InternalProperties (org.eclipse.elk.alg.layered.options.InternalProperties)8 Set (java.util.Set)7 LayeredOptions (org.eclipse.elk.alg.layered.options.LayeredOptions)7 Map (java.util.Map)6 IElkProgressMonitor (org.eclipse.elk.core.util.IElkProgressMonitor)6 Lists (com.google.common.collect.Lists)5 Iterator (java.util.Iterator)5 ElkRectangle (org.eclipse.elk.core.math.ElkRectangle)5 Pair (org.eclipse.elk.core.util.Pair)5