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);
}
}
}
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);
}
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);
}
}
}
}
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);
}
}
}
}
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;
}
Aggregations