public void testBoundaries() {
    // cut and paste from single link
    CompleteLinkClusterer<String> clusterer =
        new CompleteLinkClusterer<String>(SingleLinkClustererTest.TEST_DISTANCE);

    Set<String> elts0 = new HashSet<String>();
    try {
      clusterer.hierarchicalCluster(elts0);
      fail();
    } catch (IllegalArgumentException iae) {
      succeed();
    }
    Set<Set<String>> clusters = clusterer.cluster(elts0);
    assertEquals(0, clusters.size());

    Set<String> elts1 = new HashSet<String>();
    elts1.add("A");
    Set<Set<String>> clustering = new HashSet<Set<String>>();
    clustering.add(elts1);
    assertEquals(clustering, clusterer.cluster(elts1));
    Dendrogram<String> dendro1 = clusterer.hierarchicalCluster(elts1);
    assertTrue(dendro1 instanceof LeafDendrogram);
    assertEquals(elts1, dendro1.memberSet());
    assertEquals(0.0, dendro1.score(), 0.001);
  }
  public void testOne() {

    CompleteLinkClusterer<String> clusterer =
        new CompleteLinkClusterer<String>(SingleLinkClustererTest.TEST_DISTANCE);

    Set<String> elts = new HashSet<String>();
    elts.add("A");
    elts.add("B");
    elts.add("C");
    elts.add("D");
    elts.add("E");
    Dendrogram<String> dendro = clusterer.hierarchicalCluster(elts);

    Set<String> a = new HashSet<String>();
    a.add("A");
    Set<String> b = new HashSet<String>();
    b.add("B");
    Set<String> c = new HashSet<String>();
    c.add("C");
    Set<String> d = new HashSet<String>();
    d.add("D");
    Set<String> e = new HashSet<String>();
    e.add("E");

    Set<String> ab = new HashSet<String>();
    ab.addAll(a);
    ab.addAll(b);

    Set<String> abc = new HashSet<String>();
    abc.addAll(ab);
    abc.addAll(c);

    Set<String> de = new HashSet<String>();
    de.addAll(d);
    de.addAll(e);

    Set<String> abcde = new HashSet<String>();
    abcde.addAll(abc);
    abcde.addAll(de);

    assertEquals(abcde, dendro.memberSet());

    Set<Set<String>> p1 = new HashSet<Set<String>>();
    p1.add(abcde);
    assertEquals(p1, dendro.partitionK(1));

    Set<Set<String>> p2 = new HashSet<Set<String>>();
    p2.add(abc);
    p2.add(de);
    assertEquals(p2, dendro.partitionK(2));

    Set<Set<String>> p3 = new HashSet<Set<String>>();
    p3.add(abc);
    p3.add(d);
    p3.add(e);
    assertEquals(p3, dendro.partitionK(3));

    Set<Set<String>> p4 = new HashSet<Set<String>>();
    p4.add(ab);
    p4.add(c);
    p4.add(d);
    p4.add(e);
    assertEquals(p4, dendro.partitionK(4));

    Set<Set<String>> p5 = new HashSet<Set<String>>();
    p5.add(a);
    p5.add(b);
    p5.add(c);
    p5.add(d);
    p5.add(e);
    assertEquals(p5, dendro.partitionK(5));

    assertEquals(9.0, dendro.score(), 0.001);

    try {
      dendro.partitionK(0);
      fail();
    } catch (IllegalArgumentException iae) {
      succeed();
    }

    try {
      dendro.partitionK(6);
      fail();
    } catch (IllegalArgumentException iae) {
      succeed();
    }
  }