From d0383f96d55a5c6b8ed62fe702a627ace2ae43e7 Mon Sep 17 00:00:00 2001 From: Dimitri Date: Mon, 23 Aug 2021 17:21:57 +1100 Subject: [PATCH] In PropConnected and PropNbCC: modify the part that removes unreachable nodes to ensure that it only removes nodes that are in the domain to the variables,. This was not the case and caused useless calls to removeNode --- .../constraints/graph/connectivity/PropConnected.java | 6 ++++-- .../solver/constraints/graph/connectivity/PropNbCC.java | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/solver/src/main/java/org/chocosolver/solver/constraints/graph/connectivity/PropConnected.java b/solver/src/main/java/org/chocosolver/solver/constraints/graph/connectivity/PropConnected.java index f4d5f161ba..5eadc5b11b 100755 --- a/solver/src/main/java/org/chocosolver/solver/constraints/graph/connectivity/PropConnected.java +++ b/solver/src/main/java/org/chocosolver/solver/constraints/graph/connectivity/PropConnected.java @@ -74,8 +74,10 @@ public void propagate(int evtmask) throws ContradictionException { visited.clear(); int root = g.getMandatoryNodes().iterator().next(); helper.exploreFrom(root, visited); - for (int o = visited.nextClearBit(0); o < n; o = visited.nextClearBit(o + 1)) { - g.removeNode(o, this); + for (int o : g.getPotentialNodes()) { + if (!visited.get(o)) { + g.removeNode(o, this); + } } // 2 --- enforce articulation points and bridges that link two mandatory nodes diff --git a/solver/src/main/java/org/chocosolver/solver/constraints/graph/connectivity/PropNbCC.java b/solver/src/main/java/org/chocosolver/solver/constraints/graph/connectivity/PropNbCC.java index 49b9f31446..0847c3b79b 100755 --- a/solver/src/main/java/org/chocosolver/solver/constraints/graph/connectivity/PropNbCC.java +++ b/solver/src/main/java/org/chocosolver/solver/constraints/graph/connectivity/PropNbCC.java @@ -83,8 +83,10 @@ public void propagate(int evtmask) throws ContradictionException { // 1 --- remove unreachable nodes int n = g.getNbMaxNodes(); - for (int o = visitedMin.nextClearBit(0); o < n; o = visitedMin.nextClearBit(o + 1)) { - g.removeNode(o, this); + for (int o : g.getPotentialNodes()) { + if (!visitedMin.get(o)) { + g.removeNode(o, this); + } } // 2 --- enforce articulation points and bridges that link two mandatory nodes