public void test2() { WriteLine("Generating the normal samples spacial points. "); double[] mu1 = new double[] { 200, 0 }, mu2 = new double[] { -200, 0 }; double sd = 50; int EachClusterSize = 100; // SpacialPoint ExpectedCenter1 = new SpacialPoint(mu1); // SpacialPoint ExpectedCenter2 = new SpacialPoint(mu2); WriteLine($"2 hypothetical centers: [[{mu1[0]}, {mu1[1]}], [{mu2[0]},{mu2[1]}],"); int Counter = 10; WriteLine("Average Normalized Deviations from centroid to centers"); while (--Counter != 0) { Point[] samples1 = SpatialPoint.NormalRandomPoints(mu1, sd, EachClusterSize); Point[] samples2 = SpatialPoint.NormalRandomPoints(mu2, sd, EachClusterSize); Point[] merged = new Point[samples1.Length + samples2.Length]; Array.Copy(samples1, 0, merged, 0, samples1.Length); Array.Copy(samples2, 0, merged, samples1.Length, samples2.Length); KMinSpanningTree Kmst = new KMinSpanningTree(merged); WriteLine("------------------------Centroids:----------------------------------"); Point[][] SetOfClusters = MakeNestedArrayFomPointCollection(Kmst.KSpanningTree); SaveTheClustersToJson($"tests_output/test2_clusters{Counter}.json", SetOfClusters); } }
public void Test1() { Point[] Points = new Point[] { new SpatialPoint(new int[] { 1, 0 }), new SpatialPoint(new int[] { 2, 0 }), new SpatialPoint(new int[] { 3, 0 }), new SpatialPoint(new int[] { 3, 10 }), new SpatialPoint(new int[] { 4, 0 }) }; KMinSpanningTree Kmst = new KMinSpanningTree(Points); Kmst.KMinKruskal(); IImmutableSet <Edge> ChosenEdges = Kmst.ChosenEdges; WriteLine($"The clustering threshold: {Kmst.ClusterSizeThreshold}"); Assert.IsTrue(ChosenEdges.Count != 0); foreach (Edge e in Kmst.ChosenEdges) { WriteLine($"{e}"); } foreach (PointCollection pc in Kmst.KSpanningTree) { WriteLine(pc); } }