code: private int reduce( int a, int[] labels ) {
          if (labels[a] == a) {
              return a;
          } else {
              return reduce(labels[a], labels);
          }
      }
docs: Reduces the number of labels.
  @param labels