예제 #1
0
        public void DtoK()
        {
            Klass.CopyDots(Klass.Kls_to_List(gls), old_Dots);
            Fill_clr(clr);
            Klass none = gls[0];

            foreach (Klass k in gls)
            {
                if (k.name != "none")
                {
                    Klass.AppendDots(k, gls[0]);
                }
            }
            gls.Clear();
            gls.Add(none);
            List <Dot> tempDots = new List <Dot>();

            tempDots.AddRange(Klass.Kls_to_List(gls));
            foreach (Dot d in tempDots)
            {
                generate_class();
                gls.Last().Add(d);
                gls.First().Remove(d);
            }
            RefreshAll();
        }
예제 #2
0
        private void Button12_Click_1(object sender, EventArgs e)
        {
            try
            {
                Klass.CopyDots(Klass.Kls_to_List(gls), old_Dots);
                Fill_clr(clr);
                Random     rnd     = new Random();
                List <Dot> centers = new List <Dot>();
                Klass      none    = gls[0];
                foreach (Klass k in gls)
                {
                    if (k.name != "none")
                    {
                        Klass.AppendDots(k, gls[0]);
                    }
                }
                gls.Clear();
                gls.Add(none);
                Dots.Clear();
                Dots.AddRange(Klass.Kls_to_List(gls));

                if (graph_method.SelectedItem.ToString() == "Мин. остовное дерево (алгоритм Прима)")
                {
                    Rebro.Prim(Dots, bros, metric, Convert.ToInt32(klasters.Text));
                }
                if (graph_method.SelectedItem.ToString() == "Выделение связных компонент")
                {
                    Rebro.Build_from_R(Dots, bros, metric, Convert.ToInt32(Rbox.Text));
                }

                Klass.lab4(gls, bros);
                foreach (Klass k in gls)
                {
                    if (k.name != "none")
                    {
                        k.clr_name = clr[rnd.Next(0, clr.Count - 1)];
                        clr.Remove(k.clr_name);
                    }
                }
                RefreshScreen();
                RefreshAll();
            }
            catch { }
        }
예제 #3
0
        private void button8_Click(object sender, EventArgs e)
        {
            try
            {
                Klass.CopyDots(Klass.Kls_to_List(gls), old_Dots);
                //CopyDots(Dots, old_Dots);

                Fill_clr(clr);

                List <Dot> centers = new List <Dot>();

                Klass none = gls[0];
                foreach (Klass k in gls)
                {
                    if (k.name != "none")
                    {
                        Klass.AppendDots(k, gls[0]);
                    }
                }
                gls.Clear();
                gls.Add(none);

                generate_class(Convert.ToInt32(klasters.Text));

                Klass.Generate(centers, 2, 300, gls.Count - 1, 1, metric, "none", 0);
                //Dot.Generate(centers, 2, gls.Count - 1, 1, 300, "none", 0);
                for (int i = 0; i < gls.Count - 1; i++)
                {
                    centers[i].class_name = gls[i + 1].name;
                    centers[i].clr_name   = gls[i + 1].clr_name;
                }
                //Klass.Kmeans(Dots, centers, metric);
                Klass.Kmeans(gls[0].Dots, centers, metric);

                //Dot.kmeans(Dots, centers);
                class_centers.Clear();
                class_centers.AddRange(centers);
                RefreshAll();
            }
            catch { }
        }