Program: 58498
Project: 58498
Buggy source:
/** 
 * The pmlcluster routine performs clustering using pairwise maximum- (complete-) linking on the given distance matrix.
 * @param eClustererType
 * @return virtual array with ordered indexes
 */
private IVirtualArray pmlcluster(EClustererType eClustererType){
  int[] clusterid=new int[iNrSamples];
  Node[] result=new Node[iNrSamples - 1];
  for (int j=0; j < iNrSamples; j++)   clusterid[j]=j;
  ArrayList<Integer> AlIndexes=new ArrayList<Integer>();
  int j;
  ClosestPair pair=null;
  float[][] distmatrix;
  try {
    distmatrix=new float[iNrSamples][iNrSamples];
  }
 catch (  OutOfMemoryError e) {
    return null;
  }
  distmatrix=similarities.clone();
  int iPercentage=1;
  if (eClustererType == EClustererType.GENE_CLUSTERING)   GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
 else   GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
  for (int n=iNrSamples; n > 1; n--) {
    if (bClusteringCanceled == false) {
      int tempPercentage=(int)((float)(iNrSamples - n) / iNrSamples * 100);
      if (iPercentage == tempPercentage) {
        GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(iPercentage,false));
        iPercentage++;
      }
      int is=1;
      int js=0;
      pair=find_closest_pair(n,distmatrix);
      if (pair.update) {
        is=pair.x;
        js=pair.y;
      }
      for (j=0; j < js; j++)       distmatrix[js][j]=Math.max(distmatrix[is][j],distmatrix[js][j]);
      for (j=js + 1; j < is; j++)       distmatrix[j][js]=Math.max(distmatrix[is][j],distmatrix[j][js]);
      for (j=is + 1; j < n; j++)       distmatrix[j][js]=Math.max(distmatrix[j][is],distmatrix[j][js]);
      for (j=0; j < is; j++)       distmatrix[is][j]=distmatrix[n - 1][j];
      for (j=is + 1; j < n - 1; j++)       distmatrix[j][is]=distmatrix[n - 1][j];
      Node node=new Node();
      node.setCorrelation(pair.correlation);
      node.setLeft(clusterid[is]);
      node.setRight(clusterid[js]);
      result[iNrSamples - n]=node;
      clusterid[js]=n - iNrSamples - 1;
      clusterid[is]=clusterid[n - 1];
      processEvents();
    }
 else {
      GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
      return null;
    }
  }
  tree=new Tree<ClusterNode>();
  ClusterNode node=new ClusterNode("String_Node_Str",getNodeCounter(),0f,0,true,-1);
  tree.setRootNode(node);
  treeStructureToTree(node,result,result.length - 1,eClustererType);
  ClusterHelper.determineNrElements(tree);
  ClusterHelper.determineHierarchyDepth(tree);
  determineExpressionValue(eClustererType);
  AlIndexes=ClusterHelper.getGeneIdsOfNode(tree,tree.getRoot());
  if (eClustererType == EClustererType.GENE_CLUSTERING)   set.setClusteredTreeGenes(tree);
 else   set.setClusteredTreeExps(tree);
  IVirtualArray virtualArray=null;
  if (eClustererType == EClustererType.GENE_CLUSTERING)   virtualArray=new VirtualArray(set.getVA(iVAIdContent).getVAType(),set.depth(),AlIndexes);
 else   if (eClustererType == EClustererType.EXPERIMENTS_CLUSTERING)   virtualArray=new VirtualArray(set.getVA(iVAIdStorage).getVAType(),set.size(),AlIndexes);
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(iProgressBarMultiplier * 50 + iProgressBarOffsetValue,true));
  return virtualArray;
}

Fixed version (ground truth):
/** 
 * The pmlcluster routine performs clustering using pairwise maximum- (complete-) linking on the given distance matrix.
 * @param eClustererType
 * @return virtual array with ordered indexes
 */
private IVirtualArray pmlcluster(EClustererType eClustererType){
  int[] clusterid=new int[iNrSamples];
  Node[] result=new Node[iNrSamples - 1];
  for (int j=0; j < iNrSamples; j++)   clusterid[j]=j;
  ArrayList<Integer> AlIndexes=new ArrayList<Integer>();
  int j;
  ClosestPair pair=null;
  float[][] distmatrix;
  try {
    distmatrix=new float[iNrSamples][iNrSamples];
  }
 catch (  OutOfMemoryError e) {
    return null;
  }
  distmatrix=similarities.clone();
  int iPercentage=1;
  if (eClustererType == EClustererType.GENE_CLUSTERING)   GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
 else   GeneralManager.get().getEventPublisher().triggerEvent(new RenameProgressBarEvent("String_Node_Str"));
  for (int n=iNrSamples; n > 1; n--) {
    if (bClusteringCanceled == false) {
      int tempPercentage=(int)((float)(iNrSamples - n) / iNrSamples * 100);
      if (iPercentage == tempPercentage) {
        GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(iPercentage,false));
        iPercentage++;
      }
      int is=1;
      int js=0;
      pair=find_closest_pair(n,distmatrix);
      if (pair.update) {
        is=pair.x;
        js=pair.y;
      }
      for (j=0; j < js; j++)       distmatrix[js][j]=Math.max(distmatrix[is][j],distmatrix[js][j]);
      for (j=js + 1; j < is; j++)       distmatrix[j][js]=Math.max(distmatrix[is][j],distmatrix[j][js]);
      for (j=is + 1; j < n; j++)       distmatrix[j][js]=Math.max(distmatrix[j][is],distmatrix[j][js]);
      for (j=0; j < is; j++)       distmatrix[is][j]=distmatrix[n - 1][j];
      for (j=is + 1; j < n - 1; j++)       distmatrix[j][is]=distmatrix[n - 1][j];
      Node node=new Node();
      node.setCorrelation(pair.correlation);
      node.setLeft(clusterid[is]);
      node.setRight(clusterid[js]);
      result[iNrSamples - n]=node;
      clusterid[js]=n - iNrSamples - 1;
      clusterid[is]=clusterid[n - 1];
      processEvents();
    }
 else {
      GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(100,true));
      return null;
    }
  }
  tree=new Tree<ClusterNode>();
  ClusterNode node=new ClusterNode("String_Node_Str",getNodeCounter(),0f,0,true,-1);
  tree.setRootNode(node);
  treeStructureToTree(node,result,result.length - 1,eClustererType);
  ClusterHelper.determineNrElements(tree);
  ClusterHelper.determineHierarchyDepth(tree);
  ClusterHelper.determineExpressionValue(tree,eClustererType,set);
  AlIndexes=ClusterHelper.getGeneIdsOfNode(tree,tree.getRoot());
  if (eClustererType == EClustererType.GENE_CLUSTERING)   set.setClusteredTreeGenes(tree);
 else   set.setClusteredTreeExps(tree);
  IVirtualArray virtualArray=null;
  if (eClustererType == EClustererType.GENE_CLUSTERING)   virtualArray=new VirtualArray(set.getVA(iVAIdContent).getVAType(),set.depth(),AlIndexes);
 else   if (eClustererType == EClustererType.EXPERIMENTS_CLUSTERING)   virtualArray=new VirtualArray(set.getVA(iVAIdStorage).getVAType(),set.size(),AlIndexes);
  GeneralManager.get().getEventPublisher().triggerEvent(new ClusterProgressEvent(iProgressBarMultiplier * 50 + iProgressBarOffsetValue,true));
  return virtualArray;
}