Exemplo n.º 1
0
 public void CopyTour(Tour that)
 {
     for (int i = 0; i < verticesNumber; i++)
     {
         this.tourIndexes[i] = that.IndexAt(i);
     }
 }
Exemplo n.º 2
0
        public double GetTourLength(Tour tour)
        {
            double length = 0;

            for (int i = 0; i < tour.VerticesNumber; i++)
            {
                length += edges[i, tour.IndexAt(i)];
            }

            return(length);
        }
Exemplo n.º 3
0
        static public void DrawTour(Tour tour, WOGraph graph, PictureBox canvas, bool drawLabels = false)
        {
            Bitmap   bitmap   = new Bitmap(canvas.Image);
            Graphics graphics = Graphics.FromImage(bitmap);

            float arrowCapSize          = 4;
            AdjustableArrowCap arrowCap = new AdjustableArrowCap(arrowCapSize, arrowCapSize * 2);
            Pen pen = new Pen(Brushes.Red);

            pen.CustomEndCap = arrowCap;
            pen.Width        = 2;

            for (int i = 0; i < tour.VerticesNumber; i++)
            {
                graphics.FillEllipse(Brushes.Blue, graph.GetVerticeAt(i).Coordinates.X - 5,
                                     graph.GetVerticeAt(i).Coordinates.Y - 5, 10, 10);
            }

            for (int i = 0; i < tour.VerticesNumber; i++)
            {
                graphics.DrawLine(pen, graph.GetVerticeAt(i).Coordinates,
                                  graph.GetVerticeAt(tour.IndexAt(i)).Coordinates);
            }

            if (drawLabels == true)
            {
                Font font = new Font("Arial", 9);
                for (int i = 0; i < tour.VerticesNumber; i++)
                {
                    graphics.DrawString(graph.GetVerticeAt(i).Label, font, Brushes.Black, graph.GetVerticeAt(i).Coordinates.X + 10,
                                        graph.GetVerticeAt(i).Coordinates.Y - 10);
                }
            }

            canvas.Image = bitmap;
        }