public void TestOnePointInCluster() { GreedyClustering <Tuple <int, int> > clust = new GreedyClustering <Tuple <int, int> >(new Range1dSpaceInfo(), 5L); Tuple <int, int>[] array = new Tuple <int, int>[] { Tuple.Create(0, 1), Tuple.Create(1, 2), Tuple.Create(3, 4), Tuple.Create(-1, 6), Tuple.Create(8, 10) }; var indeces = clust.GetClusters(array); Assert.AreEqual(2, indeces.Length); Assert.IsTrue(indeces[0].Contains(0)); Assert.IsTrue(indeces[0].Contains(1)); Assert.IsTrue(indeces[0].Contains(2)); Assert.IsTrue(indeces[0].Contains(3)); Assert.IsTrue(indeces[1].Contains(4)); }
public void TestClusteringIntegers() { Tuple <int, int>[] toCluster = new int[] { 1, 2, 3, 9, 10, 11, 15, 16, 17, 18 }.Select(i => a(i)).ToArray(); GreedyClustering <Tuple <int, int> > c = new GreedyClustering <Tuple <int, int> >(new Range1dSpaceInfo(), 3); var res = c.GetClusters(toCluster); Assert.IsTrue(res[2].Contains(0)); Assert.IsTrue(res[2].Contains(1)); Assert.IsTrue(res[2].Contains(2)); Assert.IsTrue(res[1].Contains(3)); Assert.IsTrue(res[1].Contains(4)); Assert.IsTrue(res[1].Contains(5)); Assert.IsTrue(res[0].Contains(6)); Assert.IsTrue(res[0].Contains(7)); Assert.IsTrue(res[0].Contains(8)); Assert.IsTrue(res[0].Contains(9)); toCluster = new int[] { 1, 2, 17, 9, 10, 11, 18, 16, 3, 15 }.Select(i => a(i)).ToArray();; c = new GreedyClustering <Tuple <int, int> >(new Range1dSpaceInfo(), 3); res = c.GetClusters(toCluster); Assert.IsTrue(res[1].Contains(0)); Assert.IsTrue(res[1].Contains(1)); Assert.IsTrue(res[1].Contains(8)); Assert.IsTrue(res[2].Contains(3)); Assert.IsTrue(res[2].Contains(4)); Assert.IsTrue(res[2].Contains(5)); Assert.IsTrue(res[0].Contains(6)); Assert.IsTrue(res[0].Contains(7)); Assert.IsTrue(res[0].Contains(2)); Assert.IsTrue(res[0].Contains(9)); }