Program: 125195
Project: 125195
Buggy source:
int computeTreeSTBipartitions(List<Tree> trees,Map<Integer,Set<Vertex>> clusters){
  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(clusters,all,leaves.length);
  for (  Tree tr : trees) {
    HashSet<STBipartition> addedSoFar=new HashSet<STBipartition>();
    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();
    System.err.println("String_Node_Str" + gtAllCluster);
    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(clusters,cluster,1);
        nodeToSTCluster.put(node,cluster);
        nodeToGTCluster.put(node,gtCluster);
        if (!rooted) {
          tryAddingGeneSTBs(clusters,cluster,treeComplementary(gtCluster,leaves),null,node,addedSoFar,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(clusters,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(clusters,l_cluster,r_cluster,cluster,node,addedSoFar,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(clusters,l_cluster,r_cluster,cluster,node,addedSoFar,allInducedByGTSize);
              tryAddingGeneSTBs(clusters,r_cluster,allMinuslAndr_cluster,null,node,addedSoFar,allInducedByGTSize);
              tryAddingGeneSTBs(clusters,l_cluster,allMinuslAndr_cluster,null,node,addedSoFar,allInducedByGTSize);
              tryAddingGeneSTBs(clusters,lAndr_cluster,allMinuslAndr_cluster,null,node,addedSoFar,allInducedByGTSize);
            }
          }
 else           if (childCount == 3 && node.isRoot()) {
            STITreeCluster l_cluster=childbslist[0];
            STITreeCluster m_cluster=childbslist[1];
            STITreeCluster r_cluster=childbslist[2];
            tryAddingGeneSTBs(clusters,l_cluster,r_cluster,null,node,addedSoFar,allInducedByGTSize);
            tryAddingGeneSTBs(clusters,r_cluster,m_cluster,null,node,addedSoFar,allInducedByGTSize);
            tryAddingGeneSTBs(clusters,l_cluster,m_cluster,null,node,addedSoFar,allInducedByGTSize);
          }
 else {
            throw new RuntimeException("String_Node_Str" + tr + "String_Node_Str"+ node);
          }
        }
      }
    }
  }
  System.err.println("String_Node_Str" + geneTreeSTBCount);
  int s=0;
  for (  Integer c : geneTreeSTBCount.values()) {
    s+=c;
  }
  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" + clusters.size());
  weights=new HashMap<STBipartition,Integer>(geneTreeSTBCount.size());
  return sigmaN;
}

Fixed version (ground truth):
int computeTreeSTBipartitions(List<Tree> trees,Map<Integer,Set<Vertex>> clusters){
  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(clusters,all,leaves.length);
  for (  Tree tr : trees) {
    HashSet<STBipartition> addedSoFar=new HashSet<STBipartition>();
    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(clusters,cluster,1);
        nodeToSTCluster.put(node,cluster);
        nodeToGTCluster.put(node,gtCluster);
        if (!rooted) {
          tryAddingGeneSTBs(clusters,cluster,treeComplementary(gtCluster,leaves),null,node,addedSoFar,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(clusters,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(clusters,l_cluster,r_cluster,cluster,node,addedSoFar,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(clusters,l_cluster,r_cluster,cluster,node,addedSoFar,allInducedByGTSize);
              tryAddingGeneSTBs(clusters,r_cluster,allMinuslAndr_cluster,null,node,addedSoFar,allInducedByGTSize);
              tryAddingGeneSTBs(clusters,l_cluster,allMinuslAndr_cluster,null,node,addedSoFar,allInducedByGTSize);
              tryAddingGeneSTBs(clusters,lAndr_cluster,allMinuslAndr_cluster,null,node,addedSoFar,allInducedByGTSize);
            }
          }
 else           if (childCount == 3 && node.isRoot()) {
            STITreeCluster l_cluster=childbslist[0];
            STITreeCluster m_cluster=childbslist[1];
            STITreeCluster r_cluster=childbslist[2];
            tryAddingGeneSTBs(clusters,l_cluster,r_cluster,null,node,addedSoFar,allInducedByGTSize);
            tryAddingGeneSTBs(clusters,r_cluster,m_cluster,null,node,addedSoFar,allInducedByGTSize);
            tryAddingGeneSTBs(clusters,l_cluster,m_cluster,null,node,addedSoFar,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" + s);
  s=0;
  for (  Integer c : clusters.keySet()) {
    s+=clusters.get(c).size();
  }
  System.err.println("String_Node_Str" + clusters.size());
  weights=new HashMap<STBipartition,Integer>(geneTreeSTBCount.size());
  return sigmaN;
}