Exemplo n.º 1
0
        public static Bitmap DrawTree(int canvasWidth, int canvasHeight)
        {
            Bitmap canvas = new Bitmap(canvasWidth, canvasHeight);

            Graphics g = Graphics.FromImage(canvas);

            g.Clear(Color.White);

            //рисование рёбер
            ENode t = Edges.head;

            while (t != null)
            {
                g.DrawLine(Pens.Black, t.p1, t.p2);
                t = t.next;
            }
            // && t.next != null


            //рисование вершин
            t = Vert.head;
            while (t != null)
            {
                Rectangle r = new Rectangle(t.p1.X - RAD, t.p1.Y - RAD, 2 * RAD, 2 * RAD);
                g.FillEllipse(Brushes.Blue, r);
                t = t.next;
            }
            // && t.next != null


            return(canvas);
        }
Exemplo n.º 2
0
        //рисование
        public static Bitmap DrawTree(int canvasWidth, int canvasHeight)
        {
            Bitmap canvas = new Bitmap(canvasWidth, canvasHeight);

            Graphics g = Graphics.FromImage(canvas);

            g.Clear(Color.White);

            //рисование рёбер
            ENode t = Edges.head;

            while (t != null)
            {
                g.DrawLine(Pens.Black, t.p1, t.p2);
                t = t.next;
            }

            //рисование вершин и индексов
            t = Vert.head;
            while (t != null)
            {
                Rectangle r = new Rectangle(t.p1.X - RAD, t.p1.Y - RAD, 2 * RAD, 2 * RAD);
                g.FillEllipse(Brushes.DarkGreen, r);
                g.DrawString(t.index.ToString(), SystemFonts.DefaultFont, Brushes.White, r, new StringFormat()
                {
                    Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                });
                t = t.next;
            }
            return(canvas);
        }
Exemplo n.º 3
0
 public void Add(Point P1, Point P2)
 {
     if (head == null)
     {
         head = tail = new ENode(P1, P2);
     }
     else
     {
         tail.next = new ENode(P1, P2);
         tail      = tail.next;
     }
 }
Exemplo n.º 4
0
 public EList()
 {
     head = tail = null;
 }