Beispiel #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     
     g = new Graph(Convert.ToInt32(textBox1.Text));
     for (int i = 0; i < g.Size; i++)
     {
         comboBox1.Items.Add(i);
         comboBox2.Items.Add(i);
     }
 }
Beispiel #2
0
        public void Draw_Graph(Graph G,int A,int B,char c)
        {
            img.Add(new Bitmap(width,height));
            Graphics g = Graphics.FromImage(img[img.Count-1]);
            if(img.Count>1)
            {
                String s = "Removing ";
                s += B.ToString();
                if (c == 'c')
                    s += " covered by ";
                else if (c == 'p')
                    s += " psuedo covered by ";   
                s += A.ToString();
                if (c == 'r')
                {
                    s = "";
                    s = "Removing random node ";
                    s += A;
                }
                str.Add(s);
               //g.DrawString(s, new Font("Arial", 16), Brushes.Black, new Point(45, 20));
            }
            for(int i=0;i<G.Size;i++)
                if(G.adj[i].Count!=0)  //have no edges
                {
                    g.FillEllipse(new SolidBrush(Color.Black), new Rectangle(points[i], new Size(50, 50)));
                    g.DrawString(i.ToString(), new Font("Arial", 24), Brushes.White, new Point(points[i].X + 10, points[i].Y + 5));
                }
            for (int i = 0; i < G.Size; i++)
            {
                for (int j = 0; j < G.adj[i].Count; j++)
                {
                    Point pA = new Point();
                    Point pB = new Point();
                    pA.X = points[i].X + 25;
                    pA.Y = points[i].Y + 25;
                    pB.X = points[G.adj[i][j]].X + 25;
                    pB.Y = points[G.adj[i][j]].Y + 25;
                    Pen pen = new Pen(Color.Orange, 5);
                    g.DrawLine(pen, pA, pB);
                    g.FillEllipse(new SolidBrush(Color.Black), new Rectangle(points[i], new Size(50, 50)));
                    g.DrawString(i.ToString(), new Font("Arial", 24), Brushes.White, new Point(points[i].X + 10, points[i].Y + 5));
                    g.FillEllipse(new SolidBrush(Color.Black), new Rectangle(points[G.adj[i][j]], new Size(50, 50)));
                    g.DrawString(G.adj[i][j].ToString(), new Font("Arial", 24), Brushes.White, new Point(points[G.adj[i][j]].X + 10, points[G.adj[i][j]].Y + 5));
                }
            }

        }