Program: 21603
Project: 21603
Buggy source:
private void setNodesAndParents() throws ExceptionHugin {
  List<Attribute> atts=new ArrayList<>();
  NodeList huginNodes=this.huginBN.getNodes();
  int numNodes=huginNodes.size();
  for (int i=0; i < numNodes; i++) {
    Node n=(Node)huginNodes.get(i);
    if (n.getKind().compareTo(NetworkModel.H_KIND_DISCRETE) == 0) {
      int numStates=(int)((DiscreteChanceNode)n).getNumberOfStates();
      atts.add(new Attribute(i,n.getName(),"String_Node_Str",StateSpaceType.FINITE_SET,numStates));
    }
 else     if (n.getKind().compareTo(NetworkModel.H_KIND_CONTINUOUS) == 0) {
      atts.add(new Attribute(i,n.getName(),"String_Node_Str",StateSpaceType.REAL,0));
    }
  }
  StaticVariables staticVariables=new StaticVariables(new Attributes(atts));
  DAG dag=new DAG(staticVariables);
  StaticVariables amidstVariables=staticVariables;
  for (int i=0; i < numNodes; i++) {
    Node huginChild=(Node)huginNodes.get(i);
    NodeList huginParents=huginChild.getParents();
    Variable amidstChild=amidstVariables.getVariableByName(huginChild.getName());
    List<Integer> positionsMultinomialParents=new ArrayList<>();
    for (int j=0; j < huginParents.size(); j++) {
      Node huginParent=(Node)huginParents.get(j);
      if (huginParent.getKind().compareTo(NetworkModel.H_KIND_DISCRETE) == 0) {
        int indexParent=huginNodes.indexOf(huginParent);
        positionsMultinomialParents.add(indexParent);
      }
    }
    Collections.reverse(positionsMultinomialParents);
    for (int j=0; j < huginParents.size(); j++) {
      Node huginParent=(Node)huginParents.get(j);
      Variable amidstParent=amidstVariables.getVariableByName(huginParent.getName());
      dag.getParentSet(amidstChild).addParent(amidstParent);
    }
  }
  this.amidstBN=BayesianNetwork.newBayesianNetwork(dag);
}

Fixed version (ground truth):
private void setNodesAndParents() throws ExceptionHugin {
  List<Attribute> atts=new ArrayList<>();
  NodeList huginNodes=this.huginBN.getNodes();
  int numNodes=huginNodes.size();
  for (int i=0; i < numNodes; i++) {
    Node n=(Node)huginNodes.get(i);
    if (n.getKind().compareTo(NetworkModel.H_KIND_DISCRETE) == 0) {
      int numStates=(int)((DiscreteChanceNode)n).getNumberOfStates();
      atts.add(new Attribute(i,n.getName(),"String_Node_Str",StateSpaceType.FINITE_SET,numStates));
    }
 else     if (n.getKind().compareTo(NetworkModel.H_KIND_CONTINUOUS) == 0) {
      atts.add(new Attribute(i,n.getName(),"String_Node_Str",StateSpaceType.REAL,0));
    }
  }
  StaticVariables staticVariables=new StaticVariables(new Attributes(atts));
  DAG dag=new DAG(staticVariables);
  StaticVariables amidstVariables=staticVariables;
  for (int i=0; i < numNodes; i++) {
    Node huginChild=(Node)huginNodes.get(i);
    NodeList huginParents=huginChild.getParents();
    Variable amidstChild=amidstVariables.getVariableByName(huginChild.getName());
    for (int j=0; j < huginParents.size(); j++) {
      Node huginParent=(Node)huginParents.get(j);
      Variable amidstParent=amidstVariables.getVariableByName(huginParent.getName());
      dag.getParentSet(amidstChild).addParent(amidstParent);
    }
  }
  this.amidstBN=BayesianNetwork.newBayesianNetwork(dag);
}