Ejemplo n.º 1
0
        public double DistanceTo(City other)
        {
            var dx = other.LocationX - LocationX;
            var dy = other.LocationY - LocationY;

            return Math.Sqrt(dx * dx + dy * dy);
        }
Ejemplo n.º 2
0
        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);
        }