private void Menu_ClusterBatch_Click(object sender, EventArgs e) { // string inputFolder = @"D:\\__gDrive\\__PHD\\Input\\Generated\\_Vtx\\Test-Vtx"; string outputFolder = @"D:\\__gDrive\\__PHD\\Input\\Generated\\_Vtx\\Output-CMeans"; string[] inputFolder = new string[] { "D:\\__gDrive\\__PHD\\Input\\Generated\\_Vtx\\Test-Vtx\\arc50000_1r.vtx", "D:\\__gDrive\\__PHD\\Input\\Generated\\_Vtx\\Test-Vtx\\clus50000_4r.vtx", "D:\\__gDrive\\__PHD\\Input\\Generated\\_Vtx\\Test-Vtx\\gaus50000_4.vtx", "D:\\__gDrive\\__PHD\\Input\\Generated\\_Vtx\\Test-Vtx\\grid50000_0.vtx", "D:\\__gDrive\\__PHD\\Input\\Generated\\_Vtx\\Test-Vtx\\grid50000_4.vtx", "D:\\__gDrive\\__PHD\\Input\\Generated\\_Vtx\\Test-Vtx\\Unif50000_0.vtx", "D:\\__gDrive\\__PHD\\Input\\Generated\\_Vtx\\Test-Vtx\\Unif50000_4.vtx", "D:\\__gDrive\\__PHD\\Input\\Generated\\_Vtx\\Test-Vtx\\arc50000_0.vtx" }; //if ( Dialog_InputFolder.ShowDialog() == DialogResult.OK && // Dialog_OutputFolder.ShowDialog() == DialogResult.OK ) //{ IClustering algorithm = new CMeans(); foreach (string f in inputFolder) { //foreach ( string f in Directory.GetFiles(inputFolder) ) //{ string outputFile = Path.Combine(outputFolder, Path.GetFileNameWithoutExtension(f)); Vertex[] vertices = Loader.LoadVertices(f); int numberOfClusters = vertices.Length / 100; BoundingBox boundingBox = new BoundingBox(); boundingBox.Initialize(vertices[0].Dimension); boundingBox.AddVertices(vertices); Dictionary <string, object> properties = new Dictionary <string, object>(); properties.Add("boundingBox", boundingBox); properties.Add("numberOfClusters", numberOfClusters); properties.Add("treshold", 0.5); Array.Resize <Vertex>(ref vertices, vertices.Length + numberOfClusters); algorithm.SetProperties(properties); algorithm.ComputeClustering(vertices); List <Facility> fac = algorithm.GetFacilities(); ClusterSolution.SaveClusteringSolution(algorithm, f, outputFile, fac); } //} MessageBox.Show("Batch clustering is done!", "Clustering", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public CMeansIterator(Vertex[] vertices, BoundingBox box) : base(vertices, box) { this.algorithm = new CMeans(); originalVertices = (Vertex[])vertices.Clone(); // add some properties to particular clustering algorithms properties = new Dictionary <string, object>(); properties.Add("boundingBox", box); // TODO: here should start the alchemy -> investigate where start with number of clusters and threshold properties.Add("numberOfClusters", 10); properties.Add("treshold", 0.0); algorithm.SetProperties(properties); }