public static void TEST(Action <string> print) { Random r = new Random(); List <TestItem> featureData = new List <TestItem>(); for (int i = 0; i < 3000; i++) { featureData.Add(new TestItem(r.NextDouble(), r.NextDouble())); } for (int i = 0; i < 3000; i++) { featureData.Add(new TestItem(r.NextDouble() + 10, r.NextDouble() + 10)); } for (int i = 0; i < 3000; i++) { featureData.Add(new TestItem(r.NextDouble() - 10, r.NextDouble() - 10)); } for (int i = 0; i < 1000; i++) { featureData.Add(new TestItem(r.NextDouble() + 50, r.NextDouble() + 50)); } Stopwatch st = new Stopwatch(); st.Start(); List <IClusterable> clusters = new DbscanAlgorithm(1, 10).Clustering(featureData); st.Stop(); print("\r\ntime: " + st.ElapsedMilliseconds + " msec"); print("items count:" + featureData.Count); print("clusters count: " + clusters.Count); print(""); foreach (var c in clusters) { print(c.Distance(new TestItem(0, 0)) + ""); } }
private void button1_Click(object sender, EventArgs e) { DbscanAlgorithm.TEST(x => Console.WriteLine(x)); }