Program: 125192
Project: 125192
Buggy source:
int computeTreeSTBipartitions(List<Tree> trees){
  int sigmaN=0;
  int k=trees.size();
  String[] leaves=stTaxa;
  int n=leaves.length;
  geneTreeSTBBySize=new ArrayList<Set<STBipartition>>(leaves.length);
  for (int i=0; i <= leaves.length; i++) {
    geneTreeSTBBySize.add(new HashSet<STBipartition>());
    clusters.put(i,new HashSet<Vertex>());
  }
  geneTreeSTBCount=new HashMap<STBipartition,Integer>(k * n);
  geneTreeRootSTBs=new HashMap<STBipartition,Integer>(k * n);
  clusterToSTBs=new HashMap<STITreeCluster,Set<STBipartition>>(k * n);
  STITreeCluster all=new STITreeCluster(stTaxa);
  String as[];
  int j=(as=stTaxa).length;
  for (int i=0; i < j; i++) {
    String t=as[i];
    all.addLeaf(t);
  }
  addToClusters(all,leaves.length);
  for (  Tree tr : trees) {
    STITreeCluster allInducedByGT=new STITreeCluster(stTaxa);
    String[] gtLeaves=tr.getLeaves();
    STITreeCluster gtAllCluster=new STITreeCluster(gtLeaves);
    for (int i=0; i < gtLeaves.length; i++) {
      String l=gtLeaves[i];
      gtAllCluster.addLeaf(l);
      allInducedByGT.addLeaf(getSpeciesName(l));
    }
    int allInducedByGTSize=allInducedByGT.getClusterSize();
    sigmaN+=tr.getLeafCount() - 1;
    Map<TNode,STITreeCluster> nodeToSTCluster=new HashMap<TNode,STITreeCluster>(n);
    Map<TNode,STITreeCluster> nodeToGTCluster=new HashMap<TNode,STITreeCluster>(n);
    for (Iterator<TNode> nodeIt=tr.postTraverse().iterator(); nodeIt.hasNext(); ) {
      TNode node=nodeIt.next();
      if (node.isLeaf()) {
        String nodeName=node.getName();
        STITreeCluster gtCluster=new STITreeCluster(gtLeaves);
        gtCluster.addLeaf(nodeName);
        nodeName=getSpeciesName(nodeName);
        STITreeCluster cluster=new STITreeCluster(leaves);
        cluster.addLeaf(nodeName);
        addToClusters(cluster,1);
        nodeToSTCluster.put(node,cluster);
        nodeToGTCluster.put(node,gtCluster);
        if (!rooted) {
          tryAddingGeneSTBs(cluster,treeComplementary(gtCluster,leaves),null,node,allInducedByGTSize);
        }
      }
 else {
        int childCount=node.getChildCount();
        STITreeCluster childbslist[]=new STITreeCluster[childCount];
        BitSet bs=new BitSet(leaves.length);
        BitSet gbs=new BitSet(leaves.length);
        int index=0;
        for (Iterator iterator3=node.getChildren().iterator(); iterator3.hasNext(); ) {
          TNode child=(TNode)iterator3.next();
          childbslist[index++]=nodeToSTCluster.get(child);
          bs.or(nodeToSTCluster.get(child).getCluster());
          gbs.or(nodeToGTCluster.get(child).getCluster());
        }
        STITreeCluster gtCluster=new STITreeCluster(gtLeaves);
        gtCluster.setCluster(gbs);
        STITreeCluster cluster=new STITreeCluster(leaves);
        cluster.setCluster((BitSet)bs.clone());
        int size=cluster.getClusterSize();
        addToClusters(cluster,size);
        nodeToSTCluster.put(node,cluster);
        nodeToGTCluster.put(node,gtCluster);
        if (rooted) {
          if (index > 2) {
            throw new RuntimeException("String_Node_Str" + tr + "String_Node_Str"+ node);
          }
          STITreeCluster l_cluster=childbslist[0];
          STITreeCluster r_cluster=childbslist[1];
          tryAddingGeneSTBs(l_cluster,r_cluster,cluster,node,allInducedByGTSize);
        }
 else {
          if (childCount == 2) {
            STITreeCluster l_cluster=childbslist[0];
            STITreeCluster r_cluster=childbslist[1];
            STITreeCluster allMinuslAndr_cluster=treeComplementary(gtCluster,leaves);
            STITreeCluster lAndr_cluster=cluster;
            if (allMinuslAndr_cluster.getClusterSize() != 0) {
              tryAddingGeneSTBs(l_cluster,r_cluster,cluster,node,allInducedByGTSize);
              tryAddingGeneSTBs(r_cluster,allMinuslAndr_cluster,null,node,allInducedByGTSize);
              tryAddingGeneSTBs(l_cluster,allMinuslAndr_cluster,null,node,allInducedByGTSize);
              tryAddingGeneSTBs(lAndr_cluster,allMinuslAndr_cluster,null,node,allInducedByGTSize);
            }
          }
 else           if (childCount == 3 && node.isRoot()) {
            STITreeCluster l_cluster=childbslist[0];
            STITreeCluster m_cluster=childbslist[1];
            STITreeCluster r_cluster=childbslist[2];
            tryAddingGeneSTBs(l_cluster,r_cluster,null,node,allInducedByGTSize);
            tryAddingGeneSTBs(r_cluster,m_cluster,null,node,allInducedByGTSize);
            tryAddingGeneSTBs(l_cluster,m_cluster,null,node,allInducedByGTSize);
          }
 else {
            throw new RuntimeException("String_Node_Str" + tr + "String_Node_Str"+ node);
          }
        }
      }
    }
  }
  int s=0;
  for (  Integer c : geneTreeSTBCount.values()) {
    s+=c;
  }
  System.err.println("String_Node_Str" + geneTreeSTBCount.size());
  System.err.println("String_Node_Str" + s);
  s=0;
  for (  Integer c : clusters.keySet()) {
    s+=clusters.get(c).size();
  }
  System.err.println("String_Node_Str" + s);
  weights=new HashMap<STBipartition,Integer>(geneTreeSTBCount.size());
  return sigmaN;
}

Fixed version (ground truth):
int computeTreeSTBipartitions(List<Tree> trees,boolean duploss){
  int sigmaN=0;
  int k=trees.size();
  String[] leaves=stTaxa;
  int n=leaves.length;
  geneTreeSTBBySize=new ArrayList<Set<STBipartition>>(leaves.length);
  for (int i=0; i <= leaves.length; i++) {
    geneTreeSTBBySize.add(new HashSet<STBipartition>());
    clusters.put(i,new HashSet<Vertex>());
  }
  geneTreeSTBCount=new HashMap<STBipartition,Integer>(k * n);
  geneTreeRootSTBs=new HashMap<STBipartition,Integer>(k * n);
  clusterToSTBs=new HashMap<STITreeCluster,Set<STBipartition>>(k * n);
  STITreeCluster all=new STITreeCluster(stTaxa);
  String as[];
  int j=(as=stTaxa).length;
  for (int i=0; i < j; i++) {
    String t=as[i];
    all.addLeaf(t);
  }
  addToClusters(all,leaves.length);
  for (  Tree tr : trees) {
    STITreeCluster allInducedByGT=new STITreeCluster(stTaxa);
    String[] gtLeaves=tr.getLeaves();
    for (int i=0; i < gtLeaves.length; i++) {
      String l=gtLeaves[i];
      allInducedByGT.addLeaf(getSpeciesName(l));
    }
    int allInducedByGTSize=allInducedByGT.getClusterSize();
    sigmaN+=duploss ? (tr.getLeafCount() + 2 * allInducedByGTSize - 3) : (tr.getLeafCount() - 1);
    Map<TNode,STITreeCluster> nodeToSTCluster=new HashMap<TNode,STITreeCluster>(n);
    Map<TNode,STITreeCluster> nodeToGTCluster=new HashMap<TNode,STITreeCluster>(n);
    for (Iterator<TNode> nodeIt=tr.postTraverse().iterator(); nodeIt.hasNext(); ) {
      TNode node=nodeIt.next();
      if (node.isLeaf()) {
        String nodeName=node.getName();
        STITreeCluster gtCluster=new STITreeCluster(gtLeaves);
        gtCluster.addLeaf(nodeName);
        nodeName=getSpeciesName(nodeName);
        STITreeCluster cluster=new STITreeCluster(leaves);
        cluster.addLeaf(nodeName);
        addToClusters(cluster,1);
        nodeToSTCluster.put(node,cluster);
        nodeToGTCluster.put(node,gtCluster);
        if (!rooted) {
          tryAddingGeneSTBs(cluster,treeComplementary(gtCluster,leaves),null,node,allInducedByGTSize);
        }
      }
 else {
        int childCount=node.getChildCount();
        STITreeCluster childbslist[]=new STITreeCluster[childCount];
        BitSet bs=new BitSet(leaves.length);
        BitSet gbs=new BitSet(leaves.length);
        int index=0;
        for (Iterator iterator3=node.getChildren().iterator(); iterator3.hasNext(); ) {
          TNode child=(TNode)iterator3.next();
          childbslist[index++]=nodeToSTCluster.get(child);
          bs.or(nodeToSTCluster.get(child).getCluster());
          gbs.or(nodeToGTCluster.get(child).getCluster());
        }
        STITreeCluster gtCluster=new STITreeCluster(gtLeaves);
        gtCluster.setCluster(gbs);
        STITreeCluster cluster=new STITreeCluster(leaves);
        cluster.setCluster((BitSet)bs.clone());
        int size=cluster.getClusterSize();
        addToClusters(cluster,size);
        nodeToSTCluster.put(node,cluster);
        nodeToGTCluster.put(node,gtCluster);
        if (rooted) {
          if (index > 2) {
            throw new RuntimeException("String_Node_Str" + tr + "String_Node_Str"+ node);
          }
          STITreeCluster l_cluster=childbslist[0];
          STITreeCluster r_cluster=childbslist[1];
          tryAddingGeneSTBs(l_cluster,r_cluster,cluster,node,allInducedByGTSize);
        }
 else {
          if (childCount == 2) {
            STITreeCluster l_cluster=childbslist[0];
            STITreeCluster r_cluster=childbslist[1];
            STITreeCluster allMinuslAndr_cluster=treeComplementary(gtCluster,leaves);
            STITreeCluster lAndr_cluster=cluster;
            if (allMinuslAndr_cluster.getClusterSize() != 0) {
              tryAddingGeneSTBs(l_cluster,r_cluster,cluster,node,allInducedByGTSize);
              tryAddingGeneSTBs(r_cluster,allMinuslAndr_cluster,null,node,allInducedByGTSize);
              tryAddingGeneSTBs(l_cluster,allMinuslAndr_cluster,null,node,allInducedByGTSize);
              tryAddingGeneSTBs(lAndr_cluster,allMinuslAndr_cluster,null,node,allInducedByGTSize);
            }
          }
 else           if (childCount == 3 && node.isRoot()) {
            STITreeCluster l_cluster=childbslist[0];
            STITreeCluster m_cluster=childbslist[1];
            STITreeCluster r_cluster=childbslist[2];
            tryAddingGeneSTBs(l_cluster,r_cluster,null,node,allInducedByGTSize);
            tryAddingGeneSTBs(r_cluster,m_cluster,null,node,allInducedByGTSize);
            tryAddingGeneSTBs(l_cluster,m_cluster,null,node,allInducedByGTSize);
          }
 else {
            throw new RuntimeException("String_Node_Str" + tr + "String_Node_Str"+ node);
          }
        }
      }
    }
  }
  int s=0;
  for (  Integer c : geneTreeSTBCount.values()) {
    s+=c;
  }
  System.err.println("String_Node_Str" + geneTreeSTBCount.size());
  System.err.println("String_Node_Str" + s);
  s=0;
  for (  Integer c : clusters.keySet()) {
    s+=clusters.get(c).size();
  }
  System.err.println("String_Node_Str" + s);
  weights=new HashMap<STBipartition,Integer>(geneTreeSTBCount.size());
  return sigmaN;
}