示例#1
0
        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);
        }
示例#2
0
        private void Menu_ClusterLoad_Click(object sender, EventArgs e)
        {
            if (Dialog_OpenClusterResult.ShowDialog() == DialogResult.OK)
            {
                string inputFileVertices;
                facilities = ClusterSolution.LoadClusteringSolution(Dialog_OpenClusterResult.FileName, out inputFileVertices);

                DataSet vert = Loader.LoadVtx(inputFileVertices, int.MaxValue);

                vertices = vert.points;

                if (vertices == null)
                {
                    return;
                }
                foreach (Facility fac in facilities)
                {
                    // set reference to facility
                    foreach (int i in fac.VertexIndices)
                    {
                        vertices[i].Facility = fac;
                    }

                    vertices[fac.VertexIndex].IsFacility = true;
                }

                bBox.Initialize(vertices[0].Dimension);
                bBox.AddVertices(vertices);

                ScaleVertices();
                ShowCalculateClusterConvexHull();
                CalculateFacilitiesPosition();

                Menu_Cluster.Enabled = true;
                showPoints           = false;
                Graph.Draw();
            }
        }