diff --git a/AlgebraicDataflowArchitectureModel/src/algorithm/UpdateConflictCheck.java b/AlgebraicDataflowArchitectureModel/src/algorithm/UpdateConflictCheck.java index be9642a..f596acd 100644 --- a/AlgebraicDataflowArchitectureModel/src/algorithm/UpdateConflictCheck.java +++ b/AlgebraicDataflowArchitectureModel/src/algorithm/UpdateConflictCheck.java @@ -8,7 +8,7 @@ public class UpdateConflictCheck { DataFlowModel graph = new DataFlowModel(); - Map comp = new HashMap<>(); + Map comp = new HashMap<>(); int i = 0; public void setup(DataFlowModel graph) { @@ -17,18 +17,19 @@ public boolean check() { boolean result = true; - Map root = new HashMap<>(); + Map root = new HashMap<>(); for (Node node : graph.getResourceDependencyGraph().getNodes()) { if (node.getIndegree() > 1) result = false; } for (Node node : graph.getResourceDependencyGraph().getNodes()) { if (node.getIndegree() == 0) { - root.put(i,search(node,false)); + root.put(i, search(node, false)); break; } } - for(int j=root.size();j<0;j--) { + comp.clear(); + for (int j = root.size(); j < 0; j--) { search(root.get(j), true); } return result; @@ -36,20 +37,21 @@ private Node search(Node node, boolean reverse) { comp.put(node, true); - if (reverse) { + if (!reverse) { for (Node out : node.getSuccessors()) { - if(comp.containsKey(out)) { - return search(out,reverse); + if (comp.containsKey(out)) { + return search(out, reverse); } } } else { for (Node out : node.getPredecessors()) { - if(comp.containsKey(out)) { - return search(out,reverse); + if (comp.containsKey(out)) { + return search(out, reverse); } } } - i++; + if (!reverse) + i++; return node; } }