- private void incrementVisitedStateCounter(int stId) {
- // Increment counter for this state ID
- if (visitedStateCounter.containsKey(stId)) {
- int stateCount = visitedStateCounter.get(stId);
- visitedStateCounter.put(stId, stateCount + 1);
+ // Detect cycles in the current execution/trace
+ // We terminate the execution iff:
+ // (1) the state has been visited in the current execution
+ // (2) the state has one or more cycles that involve all the events
+ private boolean containsCyclesWithAllEvents(int stId) {
+
+ HashSet<Integer> visitedEvents = new HashSet<>();
+ boolean containsCyclesWithAllEvts = false;
+ ConflictTracker.Node currNode = stateGraph.get(stId);
+ for(ConflictTracker.Edge edge : currNode.getOutEdges()) {
+ dfsFindCycles(edge.getDst(), visitedEvents, new HashSet<>());
+ }
+ if (checkIfAllEventsInvolved(visitedEvents)) {
+ containsCyclesWithAllEvts = true;
+ }
+
+ return containsCyclesWithAllEvts;
+ }
+
+ private void dfsFindCycles(ConflictTracker.Node currNode, HashSet<Integer> visitedEvents,
+ HashSet<Integer> visitingEvents) {
+
+ // Stop when there is a cycle and record all the events
+ if (visitingEvents.contains(currNode.getId())) {
+ visitedEvents.addAll(visitingEvents);