Program: 154213
Project: 154213
Buggy source:
/** 
 * This should compute the topological ordering of propositions. Each component is either a proposition, logical gate, or transition. Logical gates and transitions only have propositions as inputs. The base propositions and input propositions should always be exempt from this ordering. The base propositions values are set from the MachineState that operations are performed on and the input propositions are set from the Moves that operations are performed on as well (if any).
 * @return The order in which the truth values of propositions need to be set.
 */
public List<Proposition> getOrdering(){
  List<Proposition> order=new LinkedList<Proposition>();
  List<Proposition> propositions=new ArrayList<Proposition>(propNet.getPropositions());
  Set<Proposition> visitedPropositions=new HashSet<Proposition>();
  Set<Proposition> unvisitedPropositions=new HashSet<Proposition>();
  visitedPropositions.addAll(basePropositions.values());
  visitedPropositions.addAll(inputPropositions.values());
  visitedPropositions.add(propNet.getInitProposition());
  unvisitedPropositions.addAll(propositions);
  unvisitedPropositions.removeAll(visitedPropositions);
  while (!unvisitedPropositions.isEmpty()) {
    Proposition nextProposition=null;
    for (    Proposition unvisitedProp : unvisitedPropositions) {
      Set<Proposition> inputs=new HashSet<Proposition>();
      Set<Component> toCheck=new HashSet<Component>();
      toCheck.add(unvisitedProp);
      while (!toCheck.isEmpty()) {
        Component comp=toCheck.iterator().next();
        for (        Component input : comp.getInputs()) {
          if (input instanceof Proposition)           inputs.add((Proposition)input);
 else           toCheck.add(input);
        }
      }
      if (visitedPropositions.containsAll(inputs)) {
        nextProposition=unvisitedProp;
        break;
      }
    }
    visitedPropositions.add(nextProposition);
    unvisitedPropositions.remove(nextProposition);
    order.add(nextProposition);
  }
  return order;
}

Fixed version (ground truth):
/** 
 * This should compute the topological ordering of propositions. Each component is either a proposition, logical gate, or transition. Logical gates and transitions only have propositions as inputs. The base propositions and input propositions should always be exempt from this ordering. The base propositions values are set from the MachineState that operations are performed on and the input propositions are set from the Moves that operations are performed on as well (if any).
 * @return The order in which the truth values of propositions need to be set.
 */
public List<Proposition> getOrdering(){
  List<Proposition> order=new LinkedList<Proposition>();
  List<Proposition> propositions=new ArrayList<Proposition>(propNet.getPropositions());
  Set<Proposition> visitedPropositions=new HashSet<Proposition>();
  Set<Proposition> unvisitedPropositions=new HashSet<Proposition>();
  visitedPropositions.addAll(basePropositions.values());
  visitedPropositions.addAll(inputPropositions.values());
  visitedPropositions.add(propNet.getInitProposition());
  unvisitedPropositions.addAll(propositions);
  unvisitedPropositions.removeAll(visitedPropositions);
  while (!unvisitedPropositions.isEmpty()) {
    Proposition nextProposition=null;
    for (    Proposition unvisitedProp : unvisitedPropositions) {
      Set<Proposition> inputs=new HashSet<Proposition>();
      Set<Component> toCheck=new HashSet<Component>();
      toCheck.add(unvisitedProp);
      while (!toCheck.isEmpty()) {
        Component comp=toCheck.iterator().next();
        toCheck.remove(comp);
        for (        Component input : comp.getInputs()) {
          if (input instanceof Proposition)           inputs.add((Proposition)input);
 else           toCheck.add(input);
        }
      }
      if (visitedPropositions.containsAll(inputs)) {
        nextProposition=unvisitedProp;
        break;
      }
    }
    visitedPropositions.add(nextProposition);
    unvisitedPropositions.remove(nextProposition);
    order.add(nextProposition);
  }
  return order;
}