private void button7_Click(object sender, EventArgs e) { if ((sel1 != -1) && (sel2 != -2)) { if (test.EdgeExists(sel1, sel2)) { MessageBox.Show("It exists"); } else { MessageBox.Show("Doesnt exist"); } } }
void UpdateStat(GraphController <int, int> t) // updates bottom pannel information { int iteratorpointer = -1; try { label10.Text = test.LastVertex.ToString(); if (test.IsValid()) { panel3.BackColor = Color.LightGreen; } else { panel3.BackColor = Color.Red; } try { iteratorpointer = test.Current(); } catch (Exception e) { iteratorpointer = -2; panel3.BackColor = Color.Red; } label6.Text = "Info: Vertices: " + t.VertexCount + " Edges: " + t.EdgeCount + " Type: "; if (!test.IslistBased()) { label6.Text += "MatrixBased"; } else { label6.Text += "ListBased"; } label6.Text += " K: " + test.Getk; if (t.EdgeExists(sel1, sel2)) { panel2.BackgroundImage = GetImageFromPath("layout\\edgeexist.png"); } else { panel2.BackgroundImage = GetImageFromPath("layout\\edgenotexist.png"); } textBox4.Text = test.GetEdgeWeight(sel1, sel2).ToString(); } catch (Exception eeee) { textBox4.Text = "N/a"; return; } }
void RenderLinks(GraphController <int, int> g, System.Drawing.Graphics gdi, Control[] ctrls)// renders links between vertices and directon markers { Bitmap buffer = new Bitmap((int)gdi.VisibleClipBounds.Width, (int)gdi.VisibleClipBounds.Height); Graphics localg = Graphics.FromImage(buffer); localg.SmoothingMode = gdi.SmoothingMode; List <Rectangle> points = new List <Rectangle>(); Pen pen = new Pen(Brushes.Black, 2); Brush br = Brushes.Gray; for (int i = 0; i < g.VertexCount; i++) { for (int j = 0; j < g.VertexCount; j++) { if (!g.EdgeExists(i, j)) { continue; } Control c1 = GetControlbyName(i.ToString(), ctrls); Control c2 = GetControlbyName(j.ToString(), ctrls); Point p1 = c1.Location + new Size(c1.Size.Width / 2, c1.Size.Height / 2); Point p2 = c2.Location + new Size(c2.Size.Width / 2, c2.Size.Height / 2); //gdi.DrawLine(pen, p1, p2); localg.DrawLine(pen, p1, p2); points.Add(new Rectangle(p2 - new Size((int)(0.199 * (p2.X - p1.X)) + 5, (int)(0.199 * (p2.Y - p1.Y)) + 5), new Size(10, 10))); } } if (g.IsDirected) { foreach (Rectangle r in points) { //gdi.FillEllipse(br, r); localg.FillEllipse(br, r); } } gdi.Clear(Color.White); gdi.DrawImageUnscaled(buffer, 0, 0); }