Example #1
0
 /**
  * Checks if there is a dependency of 'a' on 'b', i.e., whether 'b' is reachable from 'a' in the
  * graph representation of the current assignment. It is important that the current assignment is
  * acyclic; otherwise, this implementation might not terminate.
  *
  * @param a the start variable
  * @param b the goal variable
  * @return true iff 'a' depends on 'b'
  */
 boolean dependsOn(Atom a, Atom b) {
   for (Atom at : getSubsumers(a)) {
     if (!at.isGround()) {
       Atom nextVar = at.getConceptName();
       if (nextVar.equals(b)) {
         return true;
       }
       if (dependsOn(nextVar, b)) {
         return true;
       }
     }
   }
   return false;
 }
Example #2
0
 /**
  * Checks if a new assignment would make this assignment cyclic.
  *
  * @param var the variable index
  * @param at the new atom
  * @return true iff the resulting assignment would be cyclic
  */
 public boolean makesCyclic(Atom var, Atom at) {
   if (at.isGround()) return false;
   Atom conceptName = at.getConceptName();
   if (conceptName.equals(var)) return true;
   return dependsOn(conceptName, var);
 }