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(); }
private void Button3_Click(object sender, EventArgs e) { Klass.CopyDots(Klass.Kls_to_List(gls), old_Dots); //CopyDots(Dots, old_Dots); //CopyDots(Dots, old_Dots); int k = 0; if (int.TryParse(neighbours.Text, out k) || c_knn.Checked || cw_knn.Checked) { foreach (Dot d in Dots) { d.expectation = 0; } if (def_knn.Checked) { Klass.Knn(gls, k, metric); } else if (w_knn.Checked) { Klass.Knn(gls, k, 1.0, metric); } else if (c_knn.Checked) { Klass.Knn(gls, metric); } else if (cw_knn.Checked) { Klass.Knn(gls, metric, 1.0); } RefreshAll(); } }
private void Button12_Click(object sender, EventArgs e) { Klass.Metric mk = new Klass.WPGMA(); Klass.CopyDots(Klass.Kls_to_List(gls), old_Dots); //CopyDots(Dots, old_Dots); Klass.lab3(gls, metric, Convert.ToInt32(klasters.Text), mk); RefreshAll(); }
private void button7_Click(object sender, EventArgs e) { Klass.CopyDots(Klass.Kls_to_List(gls), old_Dots); //CopyDots(Dots, old_Dots); Klass.Generate(gls[classes.SelectedIndex].Dots, 2, 300, (int)numKlasters.Value, (int)numElements.Value, metric, gls[classes.SelectedIndex].name); //Klass.Generate(Dots, 2, (int)numKlasters.Value, (int)numElements.Value, 300, gls[classes.SelectedIndex].name); RefreshAll(); }
private void RefreshScreen() { pictureBox1.Image.Dispose(); pictureBox1.Image = null; Bitmap bmp = new Bitmap(300, 300);; using (Graphics g = Graphics.FromImage(bmp)) { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.Clear(Color.Black); //foreach(Dot d in Dots) if (ribs.Checked) { foreach (Rebro bro in bros) { try { g.DrawLine(new Pen(Color.Red, 2), (float)bro.from.prms[0], (float)bro.from.prms[1], (float)bro.to.prms[0], (float)bro.to.prms[1]); } catch { } } } foreach (Dot d in Klass.Kls_to_List(gls)) { SolidBrush b = new SolidBrush(Color.FromName(d.clr_name)); g.FillEllipse(b, new Rectangle((int)d.prms[0], (int)d.prms[1], 8, 8)); } if (centers.Checked) { foreach (Dot c in class_centers) { try { g.DrawLine(new Pen(Color.FromName(c.clr_name), 4), (float)c.prms[0] - 8, (float)c.prms[1] - 8, (float)c.prms[0] + 8, (float)c.prms[1] + 8); g.DrawLine(new Pen(Color.FromName(c.clr_name), 4), (float)c.prms[0] + 8, (float)c.prms[1] - 8, (float)c.prms[0] - 8, (float)c.prms[1] + 8); } catch { } } } } pictureBox1.Image = bmp; pictureBox1.Refresh(); }
private void Button13_Click(object sender, EventArgs e) { try { Klass.CopyDots(Klass.Kls_to_List(gls), old_Dots); Klass.lab3(gls, metric, Convert.ToInt32(klasters.Text), kls_metric); Check_colors(); RefreshAll(); } catch { } }
private void Button4_Click(object sender, EventArgs e) { //try //{ Klass.Metric mk = new Klass.Nearest(); Klass.CopyDots(Klass.Kls_to_List(gls), old_Dots); //CopyDots(Dots, old_Dots); Klass.lab3(gls, metric, Convert.ToInt32(klasters.Text), mk); RefreshAll(); //} //catch { } }
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 { } }
private void Button11_Click_1(object sender, EventArgs e) { try { Dots.Clear(); Dots.AddRange(Klass.Kls_to_List(gls)); if (graph_method.SelectedItem.ToString() == "Мин. остовное дерево (алгоритм Прима)") { Rebro.Prim(Dots, bros, metric); } if (graph_method.SelectedItem.ToString() == "Выделение связных компонент") { Rebro.Build_from_R(Dots, bros, metric, Convert.ToInt32(Rbox.Text)); } RefreshScreen(); } catch { } }
private void RefreshAll() { Dots.Clear(); Dots.AddRange(Klass.Kls_to_List(gls)); Klass.RefreshAll(gls); if (chart_auto.Checked) { Fill_chart(); } RefreshScreen(); dots_list.DataSource = null; dots_list.Items.Clear(); dots_list.DataSource = Dots; classes.DataSource = null; classes.Items.Clear(); classes.DataSource = gls; }
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 { } }
private void button9_Click(object sender, EventArgs e) { try { Klass.CopyDots(Klass.Kls_to_List(gls), old_Dots); Fill_clr(clr); List <Dot> centers = new List <Dot>(); if (gls.Count() - 1 == Convert.ToInt32(klasters.Text) && gls[0].Count() == 0) { centers.AddRange(class_centers); } else { Klass none = 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_debug(Dots, centers, metric); Klass.Kmeans_debug(Klass.Kls_to_List(gls), centers, metric); //Dot.kmeans_debug(Dots, centers); class_centers.Clear(); class_centers.AddRange(centers); RefreshAll(); } catch { } }
private void Fill_chart() { chad.Series[0].Points.Clear(); Dots.Clear(); Dots.AddRange(Klass.Kls_to_List(gls)); step_count.Clear(); List <Rebro> tempbros = new List <Rebro>(); Rebro.Build_full(Dots, tempbros, metric); for (int i = 0; i < chart_step.Count; i++) { double from, to; if (i == 0) { from = 0; } else { from = chart_step[i - 1]; } to = chart_step[i]; int count = 0; foreach (Rebro bro in tempbros) { if (bro.mean > from && bro.mean <= to) { count++; } } step_count.Add(count); chad.Series[0].Points.AddXY(to, count); } tempbros.Clear(); if (r_auto.Checked) { Rbox.Text = Find_R().ToString(); } }