+ // We only flip the value of terminate once ...
+ if (!terminate && prevVisitedStates.contains(stateId) || completeFullCycle(stateId)) {
+ updateBacktrackSetsFromGraph(stateId);
+ terminate = true;
+ }
+ // If frequency > 1 then this means we have visited this stateId more than once
+ if (currVisitedStates.containsKey(stateId) && currVisitedStates.get(stateId) > 1) {
+ updateBacktrackSetsFromGraph(stateId);