code: private void clusterIt() {
  
  		dendrogram = new LinkedPair[numItems-1];
  
  
  		logger.debug("Initial matrix: \n"+matrixToString());
  
  
  		for (int m=0;m<numItems-1;m++) {
  
  			updateIndicesToCheck(m);
  			LinkedPair pair = getClosestPair();
  			merge(pair);
  			dendrogram[m] = pair;
  
  			//if (debug) {
  			//	System.out.println("Matrix after iteration "+m+" (merged "+pair.getFirst()+","+pair.getSecond()+")");
  			//	printMatrix();
  			//}
  		}
  
  	}
docs: Calculate the hierarchical clustering and store it in dendrogram array
  This is the naive implementation (o(n3)) of single linkage clustering as outlined in wikipedia:
  http://en.wikipedia.org/wiki/Single-linkage_clustering