public HierarchyCluster(double[][] r, int targetClusterNum) {
		this.r = r;
		matrix = new double[r.length][r.length];
		clusterList = new ArrayList<ArrayList<Integer>>();
		
		//init
		for (int i = 0; i < r.length; i++) {
			ArrayList<Integer> tpList = new ArrayList<Integer>();
			tpList.add(i);
			clusterList.add(tpList);
			for (int j = 0; j < r.length; j++) {
				matrix[i][j] = r[i][j];
			}
		}
		int clusterNum = r.length;
		while (clusterNum > targetClusterNum) {
			if (clusterNum % 100 == 0)
				System.out.println("clusterNum:" + clusterNum );
			int minX = 0, minY = 0;
			Double minDis = Double.MAX_VALUE;
			
			//find min distance
			for (int i = 0; i < matrix.length; i++) {
				for (int j = i + 1; j < matrix.length; j++) {
					if (matrix[i][j] >= 0 &&  matrix[i][j] < minDis){
						minDis = matrix	[i][j];
						minX = i;
						minY = j;
					}
				}
			}
			//merge two vector.
			System.out.println(minDis + "  " + minX + ", " + minY);
			merge(minX, minY);
			clusterNum--;
		}

	}