Commit e876a5c2 authored by Sebastian Vollbrecht's avatar Sebastian Vollbrecht
Browse files

Added two utility methods to the LayerStructure class.

Also inserted corresponding calls where possible.
parent d19096c1
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -370,12 +370,12 @@ public final class GraphGenerator {
			if (dst == SOURCE || dst == SINK)
				continue;

			int dstDepth = layers.getDepth(dst.getId());
			int dstDepth = layers.getDepth(dst);

			boolean hasMandatoryIncomingEdge = false;

			for (Edge<ResourceNode> incomingEdge : edgeCreator.incomingEdgesOf(dst)) {
				if (layers.getDepth(incomingEdge.getSrc().getId()) == dstDepth - 1) {
				if (layers.getDepth(incomingEdge.getSrc()) == dstDepth - 1) {
					hasMandatoryIncomingEdge = true;
					break;
				}
@@ -482,7 +482,7 @@ public final class GraphGenerator {
				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<>();

@@ -576,7 +576,7 @@ public final class GraphGenerator {
			if (src == SOURCE || src == SINK)
				continue;

			int srcLayer = layers.getDepth(src.getId());
			int srcLayer = layers.getDepth(src);

			List<ResourceNode> dstNodes = new ArrayList<>();

+1 −1
Original line number Diff line number Diff line
@@ -206,7 +206,7 @@ public class EdgeCreator extends Observable<Edge<ResourceNode>> implements EdgeC
	public boolean isEdgeValid(ResourceNode src, ResourceNode dst) {

		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;
			}
		}
+8 −8
Original line number Diff line number Diff line
@@ -323,13 +323,13 @@ public class FeasibleMinIIProperty extends Property {
		private void prependEdge(PlannedEdge edge) {

			if (highestLayer == null)
				highestLayer = layers.getDepth(edge.dst.getId());
				highestLayer = layers.getDepth(edge.dst);

			if (!isEndNodeImmutable && highestLayer == layers.getHeight() - 1)
				isEndNodeImmutable = true;

			if (lowestLayer == null)
				lowestLayer = layers.getDepth(edge.src.getId());
				lowestLayer = layers.getDepth(edge.src);
			else
				lowestLayer--;

@@ -342,13 +342,13 @@ public class FeasibleMinIIProperty extends Property {
		private void appendEdge(PlannedEdge edge) {

			if (lowestLayer == null)
				lowestLayer = layers.getDepth(edge.src.getId());
				lowestLayer = layers.getDepth(edge.src);

			if (!isStartNodeImmutable && lowestLayer == 0)
				isStartNodeImmutable = true;

			if (highestLayer == null)
				highestLayer = layers.getDepth(edge.dst.getId());
				highestLayer = layers.getDepth(edge.dst);
			else
				highestLayer++;

@@ -506,8 +506,8 @@ public class FeasibleMinIIProperty extends Property {

	private boolean moveNodesToNeighbouringLayersIfNeeded(ResourceNode n1, ResourceNode n2) {

		int firstNodeDepth = layers.getDepth(n1.getId());
		int secondNodeDepth = layers.getDepth(n2.getId());
		int firstNodeDepth = layers.getDepth(n1);
		int secondNodeDepth = layers.getDepth(n2);

		/*
		 * Only move the nodes if they are not currently located in neighbouring layers
@@ -538,7 +538,7 @@ public class FeasibleMinIIProperty extends Property {
			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 {

				candidates.add(candidate);

				int candidateDepth = layers.getDepth(candidate.getId());
				int candidateDepth = layers.getDepth(candidate);

				canBeNewSucc &= candidateDepth == path.highestLayer + 1;
				canBeNewPred &= candidateDepth == path.lowestLayer - 1;
+6 −5
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ public class InfeasibleEdgePlanner {
	private static Set<ResourceNode> getPossiblePredecessors(ResourceNode node, StartConfiguration startCfg,
															 InfeasibleConfiguration infeasibleCfg) {

		int nodeDepth = infeasibleCfg.getLayers().getDepth(node.getId());
		int nodeDepth = infeasibleCfg.getLayers().getDepth(node);

		if (nodeDepth == startCfg.getDestinationNodeLayer() + 1) {
			return JavaUtils.asSet(startCfg.getDestinationNode());
@@ -233,8 +233,9 @@ public class InfeasibleEdgePlanner {
		 * 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.
		 */
		for (ResourceNode node : JavaUtils.asSortedList(infeasibleCfg.getProblematicNodes(), Comparator
				.comparingInt(n -> infeasibleCfg.getLayers().getDepth(n.getId())))) {
		for (ResourceNode node : JavaUtils.asSortedList(infeasibleCfg.getProblematicNodes(),
														Comparator.comparingInt(infeasibleCfg.getLayers()::getDepth)
		)) {
			makeNodeSlotProblematic(node, problematicEdgesDelay, incomingEdgesByNode, fixedEdges);
		}

@@ -330,11 +331,11 @@ public class InfeasibleEdgePlanner {
			 */
			if (startCfg.getProblematicResource().delay == 0) {

				int sourceNodeDepth = startCfg.getLayers().getDepth(fixedNode.getId());
				int sourceNodeDepth = startCfg.getLayers().getDepth(fixedNode);

				for (ResourceNode dst : infeasibleCfg.getFixedNodes()) {

					if (startCfg.getLayers().getDepth(dst.getId()) <= sourceNodeDepth) {
					if (startCfg.getLayers().getDepth(dst) <= sourceNodeDepth) {
						continue;
					}

+2 −2
Original line number Diff line number Diff line
@@ -295,8 +295,8 @@ public class InfeasibleMinIIProperty extends Property {
		 * could be replaced by zero nodes if a lower problematic node required one to
		 * be placed in the respective layer.
		 */
		for (ResourceNode problematicNode : JavaUtils.asSortedList(infeasibleCfg.getProblematicNodes(), Comparator
				.comparingInt(n -> layers.getDepth(n.getId())))) {
		for (ResourceNode problematicNode : JavaUtils
				.asSortedList(infeasibleCfg.getProblematicNodes(), Comparator.comparingInt(layers::getDepth))) {

			/*
			 * If a problematic node has been fixed already, we don't need to place it
Loading