code: private void merge(Integer cid1, Integer cid2) {
      Collection<String> klass1 = classix.get(cid1);
      Collection<String> klass2 = classix.get(cid2);
  
      // if klass1 is the smaller, swap the two
      if (klass1.size() < klass2.size()) {
        Collection<String> tmp = klass2;
        klass2 = klass1;
        klass1 = tmp;
  
        Integer itmp = cid2;
        cid2 = cid1;
        cid1 = itmp;
      }
  
      // now perform the actual merge
      for (String id : klass2) {
        klass1.add(id);
        recordix.put(id, cid1);
      }
  
      // delete the smaller class, and we're done
      classix.remove(cid2);
    }
docs: Merges the two classes into a single class. The smaller class is
  removed, while the largest class is kept.