Commit e876a5c2 authored by Sebastian Vollbrecht's avatar Sebastian Vollbrecht

Added two utility methods to the LayerStructure class.

Also inserted corresponding calls where possible.
parent d19096c1
...@@ -370,12 +370,12 @@ public final class GraphGenerator { ...@@ -370,12 +370,12 @@ public final class GraphGenerator {
if (dst == SOURCE || dst == SINK) if (dst == SOURCE || dst == SINK)
continue; continue;
int dstDepth = layers.getDepth(dst.getId()); int dstDepth = layers.getDepth(dst);
boolean hasMandatoryIncomingEdge = false; boolean hasMandatoryIncomingEdge = false;
for (Edge<ResourceNode> incomingEdge : edgeCreator.incomingEdgesOf(dst)) { for (Edge<ResourceNode> incomingEdge : edgeCreator.incomingEdgesOf(dst)) {
if (layers.getDepth(incomingEdge.getSrc().getId()) == dstDepth - 1) { if (layers.getDepth(incomingEdge.getSrc()) == dstDepth - 1) {
hasMandatoryIncomingEdge = true; hasMandatoryIncomingEdge = true;
break; break;
} }
...@@ -482,7 +482,7 @@ public final class GraphGenerator { ...@@ -482,7 +482,7 @@ public final class GraphGenerator {
out.println("\t\tTrying to generate an outgoing edge for node " + src); out.println("\t\tTrying to generate an outgoing edge for node " + src);
} }
int srcDepth = layers.getDepth(src.getId()); int srcDepth = layers.getDepth(src);
Set<ResourceNode> dstCandidates = new HashSet<>(); Set<ResourceNode> dstCandidates = new HashSet<>();
...@@ -576,7 +576,7 @@ public final class GraphGenerator { ...@@ -576,7 +576,7 @@ public final class GraphGenerator {
if (src == SOURCE || src == SINK) if (src == SOURCE || src == SINK)
continue; continue;
int srcLayer = layers.getDepth(src.getId()); int srcLayer = layers.getDepth(src);
List<ResourceNode> dstNodes = new ArrayList<>(); List<ResourceNode> dstNodes = new ArrayList<>();
......
...@@ -206,7 +206,7 @@ public class EdgeCreator extends Observable<Edge<ResourceNode>> implements EdgeC ...@@ -206,7 +206,7 @@ public class EdgeCreator extends Observable<Edge<ResourceNode>> implements EdgeC
public boolean isEdgeValid(ResourceNode src, ResourceNode dst) { public boolean isEdgeValid(ResourceNode src, ResourceNode dst) {
if (src != GraphGenerator.SOURCE && dst != GraphGenerator.SINK) { if (src != GraphGenerator.SOURCE && dst != GraphGenerator.SINK) {
if (layers.getDepth(src.getId()) >= layers.getDepth(dst.getId())) { if (layers.getDepth(src) >= layers.getDepth(dst)) {
return false; return false;
} }
} }
......
...@@ -323,13 +323,13 @@ public class FeasibleMinIIProperty extends Property { ...@@ -323,13 +323,13 @@ public class FeasibleMinIIProperty extends Property {
private void prependEdge(PlannedEdge edge) { private void prependEdge(PlannedEdge edge) {
if (highestLayer == null) if (highestLayer == null)
highestLayer = layers.getDepth(edge.dst.getId()); highestLayer = layers.getDepth(edge.dst);
if (!isEndNodeImmutable && highestLayer == layers.getHeight() - 1) if (!isEndNodeImmutable && highestLayer == layers.getHeight() - 1)
isEndNodeImmutable = true; isEndNodeImmutable = true;
if (lowestLayer == null) if (lowestLayer == null)
lowestLayer = layers.getDepth(edge.src.getId()); lowestLayer = layers.getDepth(edge.src);
else else
lowestLayer--; lowestLayer--;
...@@ -342,13 +342,13 @@ public class FeasibleMinIIProperty extends Property { ...@@ -342,13 +342,13 @@ public class FeasibleMinIIProperty extends Property {
private void appendEdge(PlannedEdge edge) { private void appendEdge(PlannedEdge edge) {
if (lowestLayer == null) if (lowestLayer == null)
lowestLayer = layers.getDepth(edge.src.getId()); lowestLayer = layers.getDepth(edge.src);
if (!isStartNodeImmutable && lowestLayer == 0) if (!isStartNodeImmutable && lowestLayer == 0)
isStartNodeImmutable = true; isStartNodeImmutable = true;
if (highestLayer == null) if (highestLayer == null)
highestLayer = layers.getDepth(edge.dst.getId()); highestLayer = layers.getDepth(edge.dst);
else else
highestLayer++; highestLayer++;
...@@ -506,8 +506,8 @@ public class FeasibleMinIIProperty extends Property { ...@@ -506,8 +506,8 @@ public class FeasibleMinIIProperty extends Property {
private boolean moveNodesToNeighbouringLayersIfNeeded(ResourceNode n1, ResourceNode n2) { private boolean moveNodesToNeighbouringLayersIfNeeded(ResourceNode n1, ResourceNode n2) {
int firstNodeDepth = layers.getDepth(n1.getId()); int firstNodeDepth = layers.getDepth(n1);
int secondNodeDepth = layers.getDepth(n2.getId()); int secondNodeDepth = layers.getDepth(n2);
/* /*
* Only move the nodes if they are not currently located in neighbouring layers * Only move the nodes if they are not currently located in neighbouring layers
...@@ -538,7 +538,7 @@ public class FeasibleMinIIProperty extends Property { ...@@ -538,7 +538,7 @@ public class FeasibleMinIIProperty extends Property {
layers.swapIDs(nodeToSwap.getId(), swapID); layers.swapIDs(nodeToSwap.getId(), swapID);
} }
return layers.getDepth(n1.getId()) < layers.getDepth(n2.getId()); return layers.getDepth(n1) < layers.getDepth(n2);
} }
...@@ -608,7 +608,7 @@ public class FeasibleMinIIProperty extends Property { ...@@ -608,7 +608,7 @@ public class FeasibleMinIIProperty extends Property {
candidates.add(candidate); candidates.add(candidate);
int candidateDepth = layers.getDepth(candidate.getId()); int candidateDepth = layers.getDepth(candidate);
canBeNewSucc &= candidateDepth == path.highestLayer + 1; canBeNewSucc &= candidateDepth == path.highestLayer + 1;
canBeNewPred &= candidateDepth == path.lowestLayer - 1; canBeNewPred &= candidateDepth == path.lowestLayer - 1;
......
...@@ -176,7 +176,7 @@ public class InfeasibleEdgePlanner { ...@@ -176,7 +176,7 @@ public class InfeasibleEdgePlanner {
private static Set<ResourceNode> getPossiblePredecessors(ResourceNode node, StartConfiguration startCfg, private static Set<ResourceNode> getPossiblePredecessors(ResourceNode node, StartConfiguration startCfg,
InfeasibleConfiguration infeasibleCfg) { InfeasibleConfiguration infeasibleCfg) {
int nodeDepth = infeasibleCfg.getLayers().getDepth(node.getId()); int nodeDepth = infeasibleCfg.getLayers().getDepth(node);
if (nodeDepth == startCfg.getDestinationNodeLayer() + 1) { if (nodeDepth == startCfg.getDestinationNodeLayer() + 1) {
return JavaUtils.asSet(startCfg.getDestinationNode()); return JavaUtils.asSet(startCfg.getDestinationNode());
...@@ -233,8 +233,9 @@ public class InfeasibleEdgePlanner { ...@@ -233,8 +233,9 @@ public class InfeasibleEdgePlanner {
* successors. Otherwise it might be possible for the summed delay (delay to the * successors. Otherwise it might be possible for the summed delay (delay to the
* zero node plus the delay to the successor) to exceed the required delay. * zero node plus the delay to the successor) to exceed the required delay.
*/ */
for (ResourceNode node : JavaUtils.asSortedList(infeasibleCfg.getProblematicNodes(), Comparator for (ResourceNode node : JavaUtils.asSortedList(infeasibleCfg.getProblematicNodes(),
.comparingInt(n -> infeasibleCfg.getLayers().getDepth(n.getId())))) { Comparator.comparingInt(infeasibleCfg.getLayers()::getDepth)
)) {
makeNodeSlotProblematic(node, problematicEdgesDelay, incomingEdgesByNode, fixedEdges); makeNodeSlotProblematic(node, problematicEdgesDelay, incomingEdgesByNode, fixedEdges);
} }
...@@ -330,11 +331,11 @@ public class InfeasibleEdgePlanner { ...@@ -330,11 +331,11 @@ public class InfeasibleEdgePlanner {
*/ */
if (startCfg.getProblematicResource().delay == 0) { if (startCfg.getProblematicResource().delay == 0) {
int sourceNodeDepth = startCfg.getLayers().getDepth(fixedNode.getId()); int sourceNodeDepth = startCfg.getLayers().getDepth(fixedNode);
for (ResourceNode dst : infeasibleCfg.getFixedNodes()) { for (ResourceNode dst : infeasibleCfg.getFixedNodes()) {
if (startCfg.getLayers().getDepth(dst.getId()) <= sourceNodeDepth) { if (startCfg.getLayers().getDepth(dst) <= sourceNodeDepth) {
continue; continue;
} }
......
...@@ -295,8 +295,8 @@ public class InfeasibleMinIIProperty extends Property { ...@@ -295,8 +295,8 @@ public class InfeasibleMinIIProperty extends Property {
* could be replaced by zero nodes if a lower problematic node required one to * could be replaced by zero nodes if a lower problematic node required one to
* be placed in the respective layer. * be placed in the respective layer.
*/ */
for (ResourceNode problematicNode : JavaUtils.asSortedList(infeasibleCfg.getProblematicNodes(), Comparator for (ResourceNode problematicNode : JavaUtils
.comparingInt(n -> layers.getDepth(n.getId())))) { .asSortedList(infeasibleCfg.getProblematicNodes(), Comparator.comparingInt(layers::getDepth))) {
/* /*
* If a problematic node has been fixed already, we don't need to place it * If a problematic node has been fixed already, we don't need to place it
......
...@@ -197,7 +197,7 @@ public class InfeasibleNodePlacer { ...@@ -197,7 +197,7 @@ public class InfeasibleNodePlacer {
} }
} }
boolean useCurrentLayer = targetLayers.contains(infeasibleCfg.getLayers().getDepth(problematicNode.getId())); boolean useCurrentLayer = targetLayers.contains(infeasibleCfg.getLayers().getDepth(problematicNode));
/* /*
* Determine the problematic node's target layer, based on our previous * Determine the problematic node's target layer, based on our previous
...@@ -207,7 +207,7 @@ public class InfeasibleNodePlacer { ...@@ -207,7 +207,7 @@ public class InfeasibleNodePlacer {
if (!useCurrentLayer) { if (!useCurrentLayer) {
targetLayer = JavaUtils.pickRandomElement(targetLayers, rng); targetLayer = JavaUtils.pickRandomElement(targetLayers, rng);
} else { } else {
targetLayer = infeasibleCfg.getLayers().getDepth(problematicNode.getId()); targetLayer = infeasibleCfg.getLayers().getDepth(problematicNode);
} }
if (!useCurrentLayer) { if (!useCurrentLayer) {
......
...@@ -94,7 +94,7 @@ public class InfeasibleConfiguration extends MinIICycleConfiguration { ...@@ -94,7 +94,7 @@ public class InfeasibleConfiguration extends MinIICycleConfiguration {
throw new IllegalArgumentException("Node " + node + " has been fixed already."); throw new IllegalArgumentException("Node " + node + " has been fixed already.");
} }
int layer = layers.getDepth(node.getId()); int layer = layers.getDepth(node);
if (problematicNodes.contains(node)) { if (problematicNodes.contains(node)) {
JavaUtils.insertOrIncValue(problematicNodesAtLayer, layer); JavaUtils.insertOrIncValue(problematicNodesAtLayer, layer);
...@@ -224,7 +224,7 @@ public class InfeasibleConfiguration extends MinIICycleConfiguration { ...@@ -224,7 +224,7 @@ public class InfeasibleConfiguration extends MinIICycleConfiguration {
*/ */
public Set<ResourceNode> getLowestProblematicNodes() { public Set<ResourceNode> getLowestProblematicNodes() {
int maxDepth = Collections.max(problematicNodesAtLayer.keySet()); int maxDepth = Collections.max(problematicNodesAtLayer.keySet());
return JavaUtils.asSet(problematicNodes.stream().filter(n -> layers.getDepth(n.getId()) == maxDepth)); return JavaUtils.asSet(problematicNodes.stream().filter(n -> layers.getDepth(n) == maxDepth));
} }
} }
...@@ -90,11 +90,11 @@ public final class LayerStructure implements Serializable, Iterable<Integer>, Ob ...@@ -90,11 +90,11 @@ public final class LayerStructure implements Serializable, Iterable<Integer>, Ob
if (firstID == secondID) if (firstID == secondID)
return; return;
if (!containsID(firstID)) { if (!contains(firstID)) {
throw new NodeDoesNotExistException(firstID, this); throw new NodeDoesNotExistException(firstID, this);
} }
if (!containsID(secondID)) { if (!contains(secondID)) {
throw new NodeDoesNotExistException(secondID, this); throw new NodeDoesNotExistException(secondID, this);
} }
...@@ -120,10 +120,20 @@ public final class LayerStructure implements Serializable, Iterable<Integer>, Ob ...@@ -120,10 +120,20 @@ public final class LayerStructure implements Serializable, Iterable<Integer>, Ob
* @param id the ID * @param id the ID
* @return true if it is contained in the layer structure, otherwise false * @return true if it is contained in the layer structure, otherwise false
*/ */
public boolean containsID(int id) { public boolean contains(int id) {
return depthsByID.containsKey(id); return depthsByID.containsKey(id);
} }
/**
* Checks whether the layer structure contains the provided node's ID.
*
* @param node the node
* @return true if its ID is contained in the layer structure, otherwise false
*/
public boolean contains(Node node) {
return contains(node.getId());
}
/** /**
* Returns an unmodifiable view of the layer at the specified depth. * Returns an unmodifiable view of the layer at the specified depth.
* *
...@@ -168,13 +178,24 @@ public final class LayerStructure implements Serializable, Iterable<Integer>, Ob ...@@ -168,13 +178,24 @@ public final class LayerStructure implements Serializable, Iterable<Integer>, Ob
*/ */
public int getDepth(int id) { public int getDepth(int id) {
if (!containsID(id)) { if (!contains(id)) {
throw new NodeDoesNotExistException(id, this); throw new NodeDoesNotExistException(id, this);
} }
return depthsByID.get(id); return depthsByID.get(id);
} }
/**
* Returns the depth of the given node, i.e. which layer its ID is currently located in.
*
* @param node the provided node
* @return the depth of the node's ID
* @throws NodeDoesNotExistException if the layer structure does not contain the ID of the provided node
*/
public int getDepth(Node node) {
return getDepth(node.getId());
}
/** /**
* Returns the relative depth of the provided ID. The relative depth is always in the inclusive interval [0, 1]. * Returns the relative depth of the provided ID. The relative depth is always in the inclusive interval [0, 1].
* *
......
...@@ -343,8 +343,8 @@ public class GraphUtils { ...@@ -343,8 +343,8 @@ public class GraphUtils {
int minDepth = Integer.MAX_VALUE; int minDepth = Integer.MAX_VALUE;
for (N src : sourceNodes) { for (N src : sourceNodes) {
if (layers.containsID(src.getId())) { if (layers.contains(src)) {
minDepth = Math.min(minDepth, layers.getDepth(src.getId())); minDepth = Math.min(minDepth, layers.getDepth(src));
} }
} }
...@@ -352,7 +352,7 @@ public class GraphUtils { ...@@ -352,7 +352,7 @@ public class GraphUtils {
for (N dst : destinationNodes) { for (N dst : destinationNodes) {
if (layers.containsID(dst.getId()) && layers.getDepth(dst.getId()) < minDepth) if (layers.contains(dst) && layers.getDepth(dst) < minDepth)
continue; continue;
worklist.offer(dst); worklist.offer(dst);
...@@ -370,7 +370,7 @@ public class GraphUtils { ...@@ -370,7 +370,7 @@ public class GraphUtils {
N src = edge.getSrc(); N src = edge.getSrc();
if (layers.containsID(src.getId()) && layers.getDepth(src.getId()) < minDepth) if (layers.contains(src) && layers.getDepth(src) < minDepth)
continue; continue;
if (!reachableNodesByNode.containsKey(src)) if (!reachableNodesByNode.containsKey(src))
...@@ -468,9 +468,9 @@ public class GraphUtils { ...@@ -468,9 +468,9 @@ public class GraphUtils {
N src = backedge.getSrc(); N src = backedge.getSrc();
N dst = backedge.getDst(); N dst = backedge.getDst();
minDepth = Math.min(minDepth, Math.min(layers.getDepth(src.getId()), layers.getDepth(dst.getId()))); minDepth = Math.min(minDepth, Math.min(layers.getDepth(src), layers.getDepth(dst)));
if (layers.getDepth(src.getId()) > layers.getDepth(dst.getId())) { if (layers.getDepth(src) > layers.getDepth(dst)) {
resultSet.add(new Edge<>(dst, src, 0, 0)); resultSet.add(new Edge<>(dst, src, 0, 0));
} }
} }
...@@ -541,7 +541,7 @@ public class GraphUtils { ...@@ -541,7 +541,7 @@ public class GraphUtils {
N src = edge.getSrc(); N src = edge.getSrc();
if (layers.getDepth(src.getId()) < minDepth) if (layers.getDepth(src) < minDepth)
continue; continue;
delays.putIfAbsent(src, new HashMap<>()); delays.putIfAbsent(src, new HashMap<>());
...@@ -560,7 +560,7 @@ public class GraphUtils { ...@@ -560,7 +560,7 @@ public class GraphUtils {
N src = edge.getSrc(); N src = edge.getSrc();
if (layers.getDepth(src.getId()) < minDepth) if (layers.getDepth(src) < minDepth)
continue; continue;
delays.putIfAbsent(src, new HashMap<>()); delays.putIfAbsent(src, new HashMap<>());
...@@ -620,13 +620,13 @@ public class GraphUtils { ...@@ -620,13 +620,13 @@ public class GraphUtils {
delays.put(sourceNode, new HashMap<>()); delays.put(sourceNode, new HashMap<>());
delays.get(sourceNode).put(sourceNode, 0); delays.get(sourceNode).put(sourceNode, 0);
int depthLimit = layers.getDepth(sourceNode.getId()); int depthLimit = layers.getDepth(sourceNode);
Queue<N> worklist = new ArrayDeque<>(); Queue<N> worklist = new ArrayDeque<>();
for (N dstNode : destinationSet) { for (N dstNode : destinationSet) {
if (layers.containsID(dstNode.getId()) && layers.getDepth(dstNode.getId()) <= depthLimit) if (layers.contains(dstNode) && layers.getDepth(dstNode) <= depthLimit)
continue; continue;
delays.putIfAbsent(dstNode, new HashMap<>()); delays.putIfAbsent(dstNode, new HashMap<>());
...@@ -636,7 +636,7 @@ public class GraphUtils { ...@@ -636,7 +636,7 @@ public class GraphUtils {
N src = edge.getSrc(); N src = edge.getSrc();
if (layers.containsID(src.getId()) && layers.getDepth(src.getId()) < depthLimit) if (layers.contains(src) && layers.getDepth(src) < depthLimit)
continue; continue;
delays.putIfAbsent(src, new HashMap<>()); delays.putIfAbsent(src, new HashMap<>());
...@@ -651,14 +651,14 @@ public class GraphUtils { ...@@ -651,14 +651,14 @@ public class GraphUtils {
N dst = worklist.poll(); N dst = worklist.poll();
if (layers.containsID(dst.getId()) && layers.getDepth(dst.getId()) <= depthLimit) if (layers.contains(dst) && layers.getDepth(dst) <= depthLimit)
continue; continue;
for (Edge<N> edge : incomingEdges.get(dst)) { for (Edge<N> edge : incomingEdges.get(dst)) {
N src = edge.getSrc(); N src = edge.getSrc();
if (layers.containsID(src.getId()) && layers.getDepth(src.getId()) < depthLimit) if (layers.contains(src) && layers.getDepth(src) < depthLimit)
continue; continue;
delays.putIfAbsent(src, new HashMap<>()); delays.putIfAbsent(src, new HashMap<>());
...@@ -720,9 +720,9 @@ public class GraphUtils { ...@@ -720,9 +720,9 @@ public class GraphUtils {
if (startNode == endNode) if (startNode == endNode)
return delays; return delays;
int maxDepth = layers.getDepth(endNode.getId()); int maxDepth = layers.getDepth(endNode);
if (layers.containsID(startNode.getId()) && layers.getDepth(startNode.getId()) >= maxDepth) if (layers.contains(startNode) && layers.getDepth(startNode) >= maxDepth)
return delays; return delays;
Queue<N> worklist = new ArrayDeque<>(); Queue<N> worklist = new ArrayDeque<>();
...@@ -732,7 +732,7 @@ public class GraphUtils { ...@@ -732,7 +732,7 @@ public class GraphUtils {
N src = edge.getSrc(); N src = edge.getSrc();
N dst = edge.getDst(); N dst = edge.getDst();
if (layers.containsID(dst.getId()) && layers.getDepth(dst.getId()) >= maxDepth && dst != endNode) if (layers.contains(dst) && layers.getDepth(dst) >= maxDepth && dst != endNode)
continue; continue;
delays.put(dst, src.getDelay() + edge.getDelay()); delays.put(dst, src.getDelay() + edge.getDelay());
...@@ -750,7 +750,7 @@ public class GraphUtils { ...@@ -750,7 +750,7 @@ public class GraphUtils {
N dst = edge.getDst(); N dst = edge.getDst();
if (layers.containsID(dst.getId()) && layers.getDepth(dst.getId()) >= maxDepth && dst != endNode) if (layers.contains(dst) && layers.getDepth(dst) >= maxDepth && dst != endNode)
continue; continue;
boolean addSuccessors = false; boolean addSuccessors = false;
...@@ -810,9 +810,9 @@ public class GraphUtils { ...@@ -810,9 +810,9 @@ public class GraphUtils {
if (startNode == endNode) if (startNode == endNode)
return delays; return delays;
int minDepth = layers.getDepth(startNode.getId()); int minDepth = layers.getDepth(startNode);
if (layers.containsID(endNode.getId()) && layers.getDepth(endNode.getId()) <= minDepth) if (layers.contains(endNode) && layers.getDepth(endNode) <= minDepth)
return delays; return delays;
Queue<N> worklist = new ArrayDeque<>(); Queue<N> worklist = new ArrayDeque<>();
...@@ -826,7 +826,7 @@ public class GraphUtils { ...@@ -826,7 +826,7 @@ public class GraphUtils {
N src = edge.getSrc(); N src = edge.getSrc();
if (layers.containsID(src.getId()) && layers.getDepth(src.getId()) <= minDepth && src != startNode) if (layers.contains(src) && layers.getDepth(src) <= minDepth && src != startNode)
continue; continue;
boolean addPredecessors = false; boolean addPredecessors = false;
......
...@@ -574,13 +574,13 @@ public class InfeasibleNodePlacerTest { ...@@ -574,13 +574,13 @@ public class InfeasibleNodePlacerTest {
placer.placeNode(node6, JavaUtils.asSet(3)); placer.placeNode(node6, JavaUtils.asSet(3));
assertEquals(3, layers.getDepth(node6.getId())); assertEquals(3, layers.getDepth(node6));
assertEquals(JavaUtils.asSet(node6), infeasibleCfg.getZeroNodesByLayer().get(3)); assertEquals(JavaUtils.asSet(node6), infeasibleCfg.getZeroNodesByLayer().get(3));
assertEquals(new Integer(1), infeasibleCfg.getProblematicNodesAtLayer().get(3)); assertEquals(new Integer(1), infeasibleCfg.getProblematicNodesAtLayer().get(3));
placer.placeNode(node8, JavaUtils.asSet(3)); placer.placeNode(node8, JavaUtils.asSet(3));
assertEquals(3, layers.getDepth(node8.getId())); assertEquals(3, layers.getDepth(node8));
assertEquals(JavaUtils.asSet(node6, node8), infeasibleCfg.getZeroNodesByLayer().get(3)); assertEquals(JavaUtils.asSet(node6, node8), infeasibleCfg.getZeroNodesByLayer().get(3));
assertEquals(new Integer(2), infeasibleCfg.getProblematicNodesAtLayer().get(3)); assertEquals(new Integer(2), infeasibleCfg.getProblematicNodesAtLayer().get(3));
...@@ -633,21 +633,21 @@ public class InfeasibleNodePlacerTest { ...@@ -633,21 +633,21 @@ public class InfeasibleNodePlacerTest {
placer.placeNode(node4, JavaUtils.asSet(2)); placer.placeNode(node4, JavaUtils.asSet(2));
assertEquals(2, layers.getDepth(node4.getId())); assertEquals(2, layers.getDepth(node4));
assertEquals(new Integer(1), infeasibleCfg.getProblematicNodesAtLayer().get(2)); assertEquals(new Integer(1), infeasibleCfg.getProblematicNodesAtLayer().get(2));
placer.placeNode(node6, JavaUtils.asSet(3)); placer.placeNode(node6, JavaUtils.asSet(3));
assertEquals(3, layers.getDepth(node6.getId())); assertEquals(3, layers.getDepth(node6));
assertEquals(JavaUtils.asSet(node5), infeasibleCfg.getZeroNodesByLayer().get(2)); assertEquals(JavaUtils.asSet(node5), infeasibleCfg.getZeroNodesByLayer().get(2));
assertEquals(2, layers.getDepth(node5.getId())); assertEquals(2, layers.getDepth(node5));
assertEquals(new Integer(1), infeasibleCfg.getProblematicNodesAtLayer().get(3)); assertEquals(new Integer(1), infeasibleCfg.getProblematicNodesAtLayer().get(3));
placer.placeNode(node8, JavaUtils.asSet(5)); placer.placeNode(node8, JavaUtils.asSet(5));
assertEquals(5, layers.getDepth(node8.getId())); assertEquals(5, layers.getDepth(node8));
assertEquals(JavaUtils.asSet(node7), infeasibleCfg.getZeroNodesByLayer().get(3)); assertEquals(JavaUtils.asSet(node7), infeasibleCfg.getZeroNodesByLayer().get(3));
assertEquals(3, layers.getDepth(node7.getId())); assertEquals(3, layers.getDepth(node7));
assertTrue(infeasibleCfg.getZeroNodesByLayer().get(4).stream().anyMatch(n -> n != node5 && n != node7)); assertTrue(infeasibleCfg.getZeroNodesByLayer().get(4).stream().anyMatch(n -> n != node5 && n != node7));
assertTrue(layers.getLayer(4).stream().map(nodeTable::get).allMatch(n -> n.getDelay() == 0)); assertTrue(layers.getLayer(4).stream().map(nodeTable::get).allMatch(n -> n.getDelay() == 0));
assertEquals(new Integer(1), infeasibleCfg.getProblematicNodesAtLayer().get(5)); assertEquals(new Integer(1), infeasibleCfg.getProblematicNodesAtLayer().get(5));
...@@ -702,19 +702,19 @@ public class InfeasibleNodePlacerTest { ...@@ -702,19 +702,19 @@ public class InfeasibleNodePlacerTest {
placer.placeNode(node4, JavaUtils.asSet(2)); placer.placeNode(node4, JavaUtils.asSet(2));
assertEquals(2, layers.getDepth(node4.getId())); assertEquals(2, layers.getDepth(node4));
assertEquals(new Integer(1), infeasibleCfg.getProblematicNodesAtLayer().get(2)); assertEquals(new Integer(1), infeasibleCfg.getProblematicNodesAtLayer().get(2));
placer.placeNode(node6, JavaUtils.asSet(3)); placer.placeNode(node6, JavaUtils.asSet(3));
assertEquals(3, layers.getDepth(node6.getId())); assertEquals(3, layers.getDepth(node6));
assertEquals(JavaUtils.asSet(node2), infeasibleCfg.getZeroNodesByLayer().get(2)); assertEquals(JavaUtils.asSet(node2), infeasibleCfg.getZeroNodesByLayer().get(2));
assertEquals(2, layers.getDepth(node2.getId())); assertEquals(2, layers.getDepth(node2));
assertEquals(new Integer(1), infeasibleCfg.getProblematicNodesAtLayer().get(3)); assertEquals(new Integer(1), infeasibleCfg.getProblematicNodesAtLayer().get(3));