コード例 #1
0
  @Test
  public void test_Cluster3() {
    IntegerCluster cluster = new IntegerCluster(20);
    int[] values = new int[] {1, 2, 3, 4, 5, 14, 27, 28, 50, 51, 52};
    int[] expectedClusterMax = new int[] {14, 14, 14, 14, 14, 14, 28, 28, 52, 52, 52};
    for (int i = 0; i < values.length; i++) cluster.add(values[i]);

    assertEquals("Expected number of clusters", 3, cluster.getClusterCount());
    for (int i = 0; i < values.length; i++)
      assertEquals(
          "Expecte max of cluster is not correct for: " + i,
          expectedClusterMax[i],
          cluster.clusterMax(values[i]));
  }
コード例 #2
0
  @Test
  public void test_Cluster() {
    IntegerCluster cluster = new IntegerCluster(20);
    int[] values =
        new int[] {
          13, 18, 13, 95,
        };
    int[] expectedClusterMax =
        new int[] {
          18, 18, 18, 95,
        };
    for (int i = 0; i < values.length; i++) cluster.add(values[i]);

    assertEquals("Expected number of clusters", 2, cluster.getClusterCount());
    for (int i = 0; i < values.length; i++)
      assertEquals(
          "Expecte max of cluster is not correct for: " + i,
          expectedClusterMax[i],
          cluster.clusterMax(values[i]));
  }