docs: private static int[] mstPartition(double[][] matrix) {
      final int n = matrix.length;
      int[] edges = PrimsMinimumSpanningTree.processDense(matrix);
      // Note: Prims does *not* yield edges sorted by edge length!
      double meanlength = thresholdLength(matrix, edges);
      int[] idx = new int[n], best = new int[n], sizes = new int[n];
      int bestsize = -1;
      double bestlen = 0;
      for(int omit = n - 2; omit > 0; --omit) {
        final double len = edgelength(matrix, edges, omit);
        if(len < meanlength) {
          continue;
        }
        omitEdge(edges, idx, sizes, omit);
        // Finalize array:
        int minsize = n;
        for(int i = 0; i < n; i++) {
          int j = idx[i] = follow(i, idx);
          if(j == i && sizes[i] < minsize) {
            minsize = sizes[i];
          }
        }
        if(minsize > bestsize || (minsize == bestsize && len > bestlen)) {
          bestsize = minsize;
          bestlen = len;
          System.arraycopy(idx, 0, best, 0, n);
        }
      }
      return best;
    }