Commit 459c0be5 authored by dinhan93's avatar dinhan93

RemoveRemove Tests with Sigma because the parameter changes the Adjacency...

RemoveRemove Tests with Sigma because the parameter changes the Adjacency Matrix and defines different clusters. Sigma with negative values are invalid.
parent e36a9b05
......@@ -104,35 +104,6 @@ public class SpectralClusteringTest extends AbstractSymtabTest{
assertTrue(labels2[3] == labels2[5]);
}
@Test
public void testSpectralClusteringN6Sigma(){
double[][] adjMatrix = {{0, 1, 1, 0, 0, 0},
{1, 0, 1, 0, 0, 0},
{1, 1, 0, 0, 1, 0},
{0, 0, 0, 0, 1, 1},
{0, 0, 1, 1, 0, 1},
{0, 0, 0, 1, 1, 0}};
SpectralClustering clustering = new SpectralClustering(adjMatrix,2,10);
int[] labels = clustering.getClusterLabel();
for (int label : labels) {
System.out.println(label);
}
System.out.println("Distortion C1S: "+clustering.distortion());
assertEquals(6, labels.length);
assertTrue(labels[0] == labels[1]);
assertTrue(labels[0] == labels[2]);
assertTrue( labels[0] == labels[4]);
assertTrue( labels[0] != labels[3]);
assertTrue( labels[0] != labels[3]);
assertTrue( labels[3] != labels[0]);
assertTrue( labels[3] == labels[5]);
}
@Test
public void testSpectralClusteringN12(){
/*
......@@ -199,74 +170,6 @@ public class SpectralClusteringTest extends AbstractSymtabTest{
assertTrue(labels2[4] == labels2[7]);
}
@Test
public void testSpectralClusteringN12Sigma(){
/*
* same Graph with 12 nodes
* we create 2 or 3 cluster Gaussian Kernel
*/
double[][] adjMatrix = {{0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
{1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0}};
SpectralClustering clustering = new SpectralClustering(adjMatrix,3, 4);
int[] labels = clustering.getClusterLabel();
for (int label : labels) {
System.out.println(label);
}
assertEquals(12, labels.length);
assertTrue(labels[0] == labels[1]);
assertTrue(labels[0] == labels[2]);
assertTrue(labels[0] == labels[3]);
assertTrue(labels[4] == labels[7]);
assertTrue(labels[4] == labels[9]);
assertTrue(labels[4] == labels[10]);
assertTrue(labels[4] != labels[5]);
assertTrue(labels[4] != labels[0]);
assertTrue(labels[5] == labels[6]);
assertTrue(labels[5] == labels[8]);
assertTrue(labels[5] == labels[11]);
assertTrue(labels[5] != labels[0]);
SpectralClustering clustering2 = new SpectralClustering(adjMatrix,2, 2);
int[] labels2 = clustering2.getClusterLabel();
for (int label : labels2) {
System.out.println(label);
}
assertEquals(12, labels2.length);
assertTrue(labels2[0] == labels2[1]);
assertTrue(labels2[0] == labels2[2]);
assertTrue(labels2[0] == labels2[3]);
assertTrue(labels2[0] == labels2[5]);
assertTrue(labels2[0] == labels2[6]);
assertTrue(labels2[0] == labels2[8]);
assertTrue(labels2[0] == labels2[11]);
assertTrue(labels2[0] != labels2[4]);
assertTrue(labels2[4] == labels2[7]);
assertTrue(labels2[4] == labels2[9]);
assertTrue(labels2[4] == labels2[10]);
assertTrue(labels2[4] != labels2[2]);
}
@Test
public void testSpectralClusteringN30(){
/*
......@@ -351,85 +254,4 @@ public class SpectralClusteringTest extends AbstractSymtabTest{
assertTrue(labels[18] != labels[0]);
}
@Test
public void testSpectralClusteringN30Sigma(){
/*
* Graph with 30 nodes
* we create 2 or 3 cluster with Gaussian Kernel
*/
double[][] adjMatrix = {{0, 1, 0, 1, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0}, //21 x 18,22,24
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0}, //22 x 21,25
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0}, //23 x 20,26
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0}, //24 x 21,25,27
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0}, //25 x 22,24,26,28
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1}, //26 x 23,25,29
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0}, //27 x 24,28
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1}, //28 x 25,27,29
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0}}; //29 x 26,28,17
SpectralClustering clustering = new SpectralClustering(adjMatrix,3,6);
int[] labels = clustering.getClusterLabel();
for (int label : labels) {
System.out.println(label);
}
System.out.println("Distortion: "+clustering.distortion());
assertEquals(30, labels.length);
assertTrue(labels[0] == labels[1]);
assertTrue(labels[0] == labels[2]);
assertTrue(labels[0] == labels[3]);
assertTrue(labels[0] == labels[4]);
assertTrue(labels[0] == labels[5]);
assertTrue(labels[0] == labels[6]);
assertTrue(labels[0] == labels[7]);
assertTrue(labels[0] == labels[8]);
assertTrue(labels[0] == labels[9]);
assertTrue(labels[0] == labels[10]);
assertTrue(labels[0] == labels[11]);
assertTrue(labels[0] == labels[12]);
assertTrue(labels[0] == labels[13]);
assertTrue(labels[0] == labels[15]);
assertTrue(labels[0] == labels[16]);
assertTrue(labels[0] != labels[14]);
assertTrue(labels[0] != labels[17]);
assertTrue(labels[18] == labels[17]);
assertTrue(labels[18] == labels[20]);
assertTrue(labels[18] == labels[22]);
assertTrue(labels[18] == labels[24]);
assertTrue(labels[18] == labels[26]);
assertTrue(labels[18] == labels[28]);
assertTrue(labels[18] != labels[14]);
assertTrue(labels[18] != labels[0]);
assertTrue(labels[14] == labels[19]);
assertTrue(labels[14] == labels[21]);
assertTrue(labels[14] == labels[23]);
assertTrue(labels[14] == labels[25]);
assertTrue(labels[14] == labels[27]);
assertTrue(labels[14] == labels[29]);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment