public static TSPCity[] RandomCities(int Count, int MaxX, int MaxY) { TSPCity[] cities = new TSPCity[Count]; Random rand = new Random(); for (int i = 0; i < Count; i++) { TSPCity city = new TSPCity(); city.x = rand.Next(MaxX); city.y = rand.Next(MaxY); cities[i] = city; } return(cities); }
private void DrawPath(Graphics g, TSPCity From, TSPCity To) { g.DrawLine(new Pen(PATH_BRUSH), From.x, From.y, To.x, To.y); }
private void DrawCity(Graphics g, TSPCity City) { g.FillEllipse(CITY_BRUSH, City.x - CITY_RADIUS, City.y - CITY_RADIUS, CITY_RADIUS * 2, CITY_RADIUS * 2); }
public double Distance(TSPCity other) { return(Math.Sqrt( Math.Pow(this.x - other.x, 2) + Math.Pow(this.y - other.y, 2))); }