public double DistanceTo(City other) { var dx = other.LocationX - LocationX; var dy = other.LocationY - LocationY; return Math.Sqrt(dx * dx + dy * dy); }
public Tour Swap(int indexOfCity1, int indexOfCity2) { var copy = new City[_route.Length]; _route.CopyTo(copy, 0); var s = copy[indexOfCity1]; copy[indexOfCity1] = copy[indexOfCity2]; copy[indexOfCity2] = s; return new Tour(copy); }