private int[] findClosestPairs(double[][] dists) {
        int k = dists.length;
        HashSet<Integer> hs = new HashSet<Integer>();
        HashSet<Integer> hs2 = new HashSet<Integer>();
        int[] pairs = new int[k];
        for (int h = 0; h < k; h++) {
            int mini = 0, minj = 0;
            double minval = Double.MAX_VALUE;
            for (int i = 0; i < k; i++) {
                if(hs.contains(i)) {
                    continue;
                }
                for (int j = 0; j < k; j++) {
                    if(hs2.contains(j)) {
                        continue;
                    }
                    if(dists[i][j] < minval) {
                        mini = i; minj = j;
                        minval = dists[i][j];
                    }
                }
            }
            pairs[mini] = minj;
            hs2.add(minj);
            hs.add(mini);
            
        }
        return pairs;
    }