From 50a6f5ad0a14d86768d472f3df8448f11455633e Mon Sep 17 00:00:00 2001 From: Soeren Domroes Date: Thu, 27 Jun 2024 15:07:03 +0200 Subject: [PATCH] WiSe24 Embedded Survey hotfixes. --- .../alg/layered/p1cycles/SCCConectivity.java | 39 ++++++++++--------- .../p1cycles/SCCModelOrderCycleBreaker.java | 36 ++++++++++++++--- .../p1cycles/SCCNodeTypeCycleBreaker.java | 37 +++++++++++------- 3 files changed, 74 insertions(+), 38 deletions(-) diff --git a/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/p1cycles/SCCConectivity.java b/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/p1cycles/SCCConectivity.java index d79344642..719ce4f8b 100644 --- a/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/p1cycles/SCCConectivity.java +++ b/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/p1cycles/SCCConectivity.java @@ -37,37 +37,40 @@ public void findNodes(int offset) { } LNode min = null; LNode max = null; + int maxGroupModelOrder = 13; int modelOrderMin = Integer.MAX_VALUE; int modelOrderMax = Integer.MIN_VALUE; + int groupModelOrderMin = Integer.MAX_VALUE; + int groupModelOrderMax = Integer.MIN_VALUE; for (LNode n : stronglyConnectedComponents.get(i)) { - // FIXME what is the layer mask? These are the group ids that are considered for this algorithm - // These have to be configurable!! - List layermask = new LinkedList(); - layermask.add(1); - layermask.add(2); - layermask.add(3); - layermask.add(4); - layermask.add(5); - layermask.add(6); - layermask.add(7); - int groupID = n.getProperty(LayeredOptions.CONSIDER_MODEL_ORDER_GROUP_I_D); - if (!layermask.contains(groupID)) { - continue; - } if (min == null || max == null) { min = n; modelOrderMin = computeConstraintModelOrder(n,offset); + groupModelOrderMin = computeConstraintGroupModelOrder(n, maxGroupModelOrder); max = n; modelOrderMax = modelOrderMin; + groupModelOrderMax = groupModelOrderMin; continue; } int modelOrderCurrent = computeConstraintModelOrder(n, offset); - if (modelOrderMin > modelOrderCurrent) { + int groupModelOrderCurrent = computeConstraintGroupModelOrder(n, maxGroupModelOrder); + if (groupModelOrderMin < groupModelOrderCurrent) { min = n; + groupModelOrderMin = groupModelOrderCurrent; modelOrderMin = modelOrderCurrent; - } - else if(modelOrderMax < modelOrderCurrent) { + } else if (groupModelOrderMin == groupModelOrderCurrent) { + if (modelOrderMin > modelOrderCurrent) { + min = n; + modelOrderMin = modelOrderCurrent; + } + } else if (groupModelOrderMax == groupModelOrderCurrent) { + if (modelOrderMax < modelOrderCurrent) { + max = n; + modelOrderMax = modelOrderCurrent; + } + } else if (groupModelOrderMax > groupModelOrderCurrent) { max = n; + groupModelOrderMax = groupModelOrderCurrent; modelOrderMax = modelOrderCurrent; } } @@ -89,4 +92,4 @@ else if(modelOrderMax < modelOrderCurrent) { } } } -} \ No newline at end of file +} diff --git a/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/p1cycles/SCCModelOrderCycleBreaker.java b/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/p1cycles/SCCModelOrderCycleBreaker.java index 12000c79a..5de83b505 100644 --- a/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/p1cycles/SCCModelOrderCycleBreaker.java +++ b/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/p1cycles/SCCModelOrderCycleBreaker.java @@ -114,12 +114,10 @@ public void findNodes(int offset) { for (LNode n : stronglyConnectedComponents.get(i)) { List groupmask = new LinkedList(); // FIXME this may not always work and should not be hard coded. - groupmask.add(1); - groupmask.add(4); - int groupID = n.getProperty(LayeredOptions.CONSIDER_MODEL_ORDER_GROUP_I_D); - if (!groupmask.contains(groupID)) { - continue; - } +// int groupID = n.getProperty(LayeredOptions.CONSIDER_MODEL_ORDER_GROUP_I_D); +// if (!groupmask.contains(groupID)) { +// continue; +// } if (max == null) { max = n; maxModelOrder = computeConstraintModelOrder(n, offset); @@ -177,6 +175,32 @@ protected int computeConstraintModelOrder(final LNode node, final int offset) { return modelOrder; } +protected int computeConstraintGroupModelOrder(final LNode node, final int offset) { + int modelOrder = 0; + switch (node.getProperty(LayeredOptions.LAYERING_LAYER_CONSTRAINT)) { + case FIRST_SEPARATE: + modelOrder = 2 * -offset + firstSeparateModelOrder; + firstSeparateModelOrder++; + break; + case FIRST: + modelOrder = -offset; + break; + case LAST: + modelOrder = offset; + break; + case LAST_SEPARATE: + modelOrder = 2 * offset + lastSeparateModelOrder; + lastSeparateModelOrder++; + break; + default: + break; + } + if (node.hasProperty(LayeredOptions.CONSIDER_MODEL_ORDER_GROUP_I_D)) { + modelOrder += node.getProperty(LayeredOptions.CONSIDER_MODEL_ORDER_GROUP_I_D); + } + return modelOrder; + } + private void TARJAN(final LGraph graph) { index = 0; stack = new Stack(); diff --git a/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/p1cycles/SCCNodeTypeCycleBreaker.java b/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/p1cycles/SCCNodeTypeCycleBreaker.java index 4dce5eaf0..832511b78 100644 --- a/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/p1cycles/SCCNodeTypeCycleBreaker.java +++ b/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/p1cycles/SCCNodeTypeCycleBreaker.java @@ -33,33 +33,42 @@ public void findNodes(int offset) { continue; } LNode min = null; + int maxGroupModelOrder = 13; // FIXME hardcoded int modelOrderMin = Integer.MAX_VALUE; + int modelOrderMax = Integer.MIN_VALUE; + int groupModelOrderMin = Integer.MAX_VALUE; + int groupModelOrderMax = Integer.MIN_VALUE; LNode max = null; - int modelOrderMax = Integer.MIN_VALUE; for (LNode n : stronglyConnectedComponents.get(i)) { - List layermask = new LinkedList(); - layermask.add(1); - layermask.add(4); - int groupID = n.getProperty(LayeredOptions.CONSIDER_MODEL_ORDER_GROUP_I_D); - if (!layermask.contains(groupID)) { - continue; - } - if (min == null && max == null) { + if (min == null || max == null) { min = n; modelOrderMin = computeConstraintModelOrder(n,offset); - + groupModelOrderMin = computeConstraintGroupModelOrder(n, maxGroupModelOrder); max = n; - modelOrderMax = computeConstraintModelOrder(n,offset); + modelOrderMax = modelOrderMin; + groupModelOrderMax = groupModelOrderMin; continue; } int modelOrderCurrent = computeConstraintModelOrder(n, offset); - if (modelOrderMin > modelOrderCurrent) { + int groupModelOrderCurrent = computeConstraintGroupModelOrder(n, maxGroupModelOrder); + if (groupModelOrderMin < groupModelOrderCurrent) { min = n; + groupModelOrderMin = groupModelOrderCurrent; modelOrderMin = modelOrderCurrent; - } - else if (modelOrderMax < modelOrderCurrent) { + } else if (groupModelOrderMin == groupModelOrderCurrent) { + if (modelOrderMin > modelOrderCurrent) { + min = n; + modelOrderMin = modelOrderCurrent; + } + } else if (groupModelOrderMax == groupModelOrderCurrent) { + if (modelOrderMax < modelOrderCurrent) { + max = n; + modelOrderMax = modelOrderCurrent; + } + } else if (groupModelOrderMax > groupModelOrderCurrent) { max = n; + groupModelOrderMax = groupModelOrderCurrent; modelOrderMax = modelOrderCurrent; } }