コード例 #1
0
ファイル: City.cs プロジェクト: nelsonsozinho/TSP-SA
        public double DistanceTo(City other)
        {
            var dx = other.LocationX - LocationX;
            var dy = other.LocationY - LocationY;

            return Math.Sqrt(dx * dx + dy * dy);
        }
コード例 #2
0
ファイル: Tour.cs プロジェクト: nelsonsozinho/TSP-SA
        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);
        }