private void findDistances()
        {
            List <double> depotDistances = new List <double>();
            List <int>    visitIds       = new List <int>();

            foreach (Visit visit in visits)
            {
                // Get x and y for visit
                int xCoordinate = visit.GetX();
                int yCoordinate = visit.GetY();

                // Set distance to depot for visit
                int xDifferenceDepot = xCoordinate - depot.GetX();
                int yDifferenceDepot = yCoordinate - depot.GetY();
                depotDistances.Add(Math.Sqrt(xDifferenceDepot * xDifferenceDepot + yDifferenceDepot * yDifferenceDepot));

                // Set distance to other visits for current visit
                List <double> distances = new List <double>();
                List <int>    ids       = new List <int>();
                foreach (Visit otherVisit in visits)
                {
                    int    xDifferenceVisits = xCoordinate - otherVisit.GetX();
                    int    yDifferenceVisits = yCoordinate - otherVisit.GetY();
                    double distance          = Math.Sqrt(xDifferenceVisits * xDifferenceVisits + yDifferenceVisits * yDifferenceVisits);
                    distances.Add(distance);

                    if (distance > maxDistance)
                    {
                        maxDistance = distance;
                    }

                    ids.Add(otherVisit.GetId());
                }
                visitDistances.Add(new VisitDistance(visit.GetId(), ids, distances));
                visitIds.Add(visit.GetId());
            }
            distancesFromDepot = new VisitDistance(0, visitIds, depotDistances);
        }
        public void Draw(RoutingPlan plan)
        {
            // FIND MAX DISTANCE
            (int, int, int, int) extrema = plan.GetExtrema();
            int maxX = extrema.Item3; //- extrema.Item1;
            int maxY = extrema.Item4; //- extrema.Item2;

            Random rand = new Random();
            using (var bmp = new Bitmap(maxX * 5, maxY * 5))
            using (var gfx = Graphics.FromImage(bmp))
            using (var pen = new Pen(Color.Black))
            {
                pen.Width = 3.0F;
                gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                gfx.Clear(Color.White);

                Visit lastVisit = plan.GetProblem().GetDepot();
                int depotX = lastVisit.GetX() * 5;
                int depotY = lastVisit.GetY() * 5;

                // Draw depot
                Rectangle rect = new Rectangle(depotX - 3, depotY - 3, 6, 6);
                gfx.DrawEllipse(pen, rect);

                PointF point1;
                PointF point2;

                foreach (Route route in plan.GetRoutes())
                {
                    pen.Color = Color.FromArgb(rand.Next());

                    // Get visits and depot
                    List<Visit> visits = route.GetVisits();

                    // Start with depot
                    int lastX = depotX;
                    int lastY = depotY;

                    foreach (Visit visit in visits)
                    {
                        // Draw visit
                        int xVisit = visit.GetX() * 5;
                        int yVisit = visit.GetY() * 5;
                        rect = new Rectangle(xVisit - 3, yVisit - 3, 6, 6);
                        gfx.DrawEllipse(pen, rect);

                        // Draw line to visit
                        point1 = new PointF(lastX, lastY);
                        point2 = new PointF(xVisit, yVisit);
                        gfx.DrawLine(pen, point1, point2);

                        // Change last visit
                        lastX = xVisit;
                        lastY = yVisit;
                    }

                    // Draw line back to depot
                    point1 = new PointF(lastX, lastY);
                    point2 = new PointF(depotX, depotY);
                    gfx.DrawLine(pen, point1, point2);
                }

                bmp.Save("RouteVisualisation.png");
            }
        }