private void Cluster_button_Click(object sender, EventArgs e)
 {
     isFuzzyClustering        = false;
     isHierarchicalClustering = false;
     for (int i = 0; i < points.Count; i++)
     {
         ((Point)points[i]).cluster_numbers.Clear();
     }
     if (LikeClassInfo_rb.Checked)
     {
         GenerationTypes form = new GenerationTypes();
         form.ShowDialog();
         if (form.isForHierarchicalClustering)
         {
             isHierarchicalClustering = true;
             dendrogram = CreateClassesDendrogram();
         }
         else if (form.isForFuzzyClustering)
         {
             isFuzzyClustering = true;
             CreateClassesMembershipMatrix();
         }
         else
         {
             for (int i = 0; i < points.Count; i++)
             {
                 ((Point)points[i]).cluster_numbers.Add((int)((ArrayList)ClassInfo[i])[0]);
             }
         }
     }
     else if (ClusteringAlgorithms_rb.Checked)
     {
         ClusteringForm form = new ClusteringForm(points, LowerBorders, UpperBorders, true);
         form.ShowDialog();
         if (form.isHierarchicalClustering)
         {
             isHierarchicalClustering = true;
             dendrogram = form.getDendrogram();
         }
         else if (form.isFuzzyClustering)
         {
             isFuzzyClustering = true;
             MembershipMatrix  = form.getMemebershipMatrix();
         }
         else
         {
             points = form.getPoints();
         }
     }
     else if (Random_rb.Checked)
     {
         GenerationTypes form = new GenerationTypes();
         form.ShowDialog();
         if (form.isWithoutNoise)
         {
             CreateRandomClustersWithoutNoise();
         }
         else if (form.isWithNoise)
         {
             CreateRandomClustersWithNoise();
         }
         else if (form.isForHierarchicalClustering)
         {
             isHierarchicalClustering = true;
             CreateRandomDendrogram();
         }
         else if (form.isForFuzzyClustering)
         {
             isFuzzyClustering = true;
             CreateRandomMembershipMatrix();
         }
     }
     isClustered = true;
     Close();
 }
示例#2
0
        private void Non_clustered_button_Click(object sender, EventArgs e)
        {
            GenerationTypes form = new GenerationTypes();

            form.ShowDialog();
            if (!form.isGenerationButtonPressed)
            {
                return;
            }
            points.Clear();
            gr.Clear(Color.White);
            SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            if (form.isForHierarchicalClustering)
            {
                GenerateForHierarchicalClustering(3, 0, 0, pictureBox.Width, pictureBox.Height, brush);
            }
            else
            {
                cluster_size = 10;
                int   radius = rand.Next(20, 60);
                int   x      = rand.Next(radius, pictureBox.Width - radius);
                int   y      = rand.Next(radius, pictureBox.Width - radius);
                Point p1     = new Point(x, y);
                CreateCluster(p1, radius, brush, form.isForFuzzyClustering);
                radius = rand.Next(20, 60);
                x      = rand.Next(radius, pictureBox.Width - radius);
                y      = rand.Next(radius, pictureBox.Width - radius);
                Point p2 = new Point(x, y);
                CreateCluster(p2, radius, brush, form.isForFuzzyClustering);
                radius = rand.Next(20, 60);
                x      = rand.Next(radius, pictureBox.Width - radius);
                y      = rand.Next(radius, pictureBox.Width - radius);
                Point p3 = new Point(x, y);
                CreateCluster(p3, radius, brush, form.isForFuzzyClustering);
                if (form.isForFuzzyClustering)
                {
                    x = (int)(((double)p1.coordinates[0] + (double)p2.coordinates[0]) / 2);
                    y = (int)(((double)p1.coordinates[1] + (double)p2.coordinates[1]) / 2);
                    Point p12 = new Point(x, y);
                    gr.FillEllipse(brush, new Rectangle(x - point_radius, y - point_radius,
                                                        2 * point_radius, 2 * point_radius));
                    points.Add(p12);
                    x = (int)(((double)p1.coordinates[0] + (double)p3.coordinates[0]) / 2);
                    y = (int)(((double)p1.coordinates[1] + (double)p3.coordinates[1]) / 2);
                    Point p13 = new Point(x, y);
                    gr.FillEllipse(brush, new Rectangle(x - point_radius, y - point_radius,
                                                        2 * point_radius, 2 * point_radius));
                    points.Add(p13);
                    x = (int)(((double)p2.coordinates[0] + (double)p3.coordinates[0]) / 2);
                    y = (int)(((double)p2.coordinates[1] + (double)p3.coordinates[1]) / 2);
                    Point p23 = new Point(x, y);
                    gr.FillEllipse(brush, new Rectangle(x - point_radius, y - point_radius,
                                                        2 * point_radius, 2 * point_radius));
                    points.Add(p23);
                }
                if (form.isWithNoise)
                {
                    noise_count = 10;
                    CreateNoise(brush);
                }
                else
                {
                    noise_count = 0;
                }
            }
            pictureBox.Image = bitmap;
        }