Program: 21710
Project: 21710
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.MULTINOMIAL,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 < huginNodes.size(); 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);
      int indexParent;
      if (huginParent.getKind().compareTo(NetworkModel.H_KIND_DISCRETE) == 0) {
        indexParent=positionsMultinomialParents.get(j);
      }
 else {
        indexParent=huginNodes.indexOf(huginParent);
      }
      Variable amidstParent=amidstVariables.getVariableByName(huginChild.getName());
      dag.getParentSet(amidstChild).addParent(amidstParent);
    }
    System.out.print(amidstChild.getName() + "String_Node_Str");
    for (    Variable var : dag.getParentSet(amidstChild))     System.out.print(var.getName() + "String_Node_Str");
    System.out.println();
  }
  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.MULTINOMIAL,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 < huginNodes.size(); 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);
    }
    System.out.print(amidstChild.getName() + "String_Node_Str");
    for (    Variable var : dag.getParentSet(amidstChild))     System.out.print(var.getName() + "String_Node_Str");
    System.out.println();
  }
  this.amidstBN=BayesianNetwork.newBayesianNetwork(dag);
}