src/demo/TSP.java
void addVisitedCity(int cityIndex) {
            visitedCities.add(cityIndex);
            int lastIndex = visitedCities.size() - 1;
            City cityFrom = cities.get(visitedCities.size() < cities.size() ? visitedCities.get(lastIndex - 1) : visitedCities.get(lastIndex));
            City cityTo = cities.get(visitedCities.size() < cities.size() ? visitedCities.get(lastIndex) : visitedCities.get(0));
            totalNormalizedDistance += cityFrom.distanceTo(cityTo, true);
            totalDistance += cityFrom.distanceTo(cityTo, false);
            if (isCompleteTour()) record();
        }
/**
         * Add visited city to tour. Updates total tour distance.
         *
         * @param cityIndex index of visited city.
         */
Add visited city to tour. Updates total tour distance.
@param cityIndex index of visited city.
Add visited city to tour . Updates total tour distance . @param cityIndex index of visited city .
void addVisitedCity(int cityIndex) {
            visitedCities.add(cityIndex);
            int lastIndex = visitedCities.size() - 1;
            City cityFrom = cities.get(visitedCities.size() < cities.size() ? visitedCities.get(lastIndex - 1) : visitedCities.get(lastIndex));
            City cityTo = cities.get(visitedCities.size() < cities.size() ? visitedCities.get(lastIndex) : visitedCities.get(0));
            totalNormalizedDistance += cityFrom.distanceTo(cityTo, true);
            totalDistance += cityFrom.distanceTo(cityTo, false);
            if (isCompleteTour()) record();
        }
void addVisitedCity ( int cityIndex ) { visitedCities . add ( cityIndex ) ; int lastIndex = visitedCities . size ( ) - 1 ; City cityFrom = cities . get ( visitedCities . size ( ) < cities . size ( ) ? visitedCities . get ( lastIndex - 1 ) : visitedCities . get ( lastIndex ) ) ; City cityTo = cities . get ( visitedCities . size ( ) < cities . size ( ) ? visitedCities . get ( lastIndex ) : visitedCities . get ( 0 ) ) ; totalNormalizedDistance += cityFrom . distanceTo ( cityTo , true ) ; totalDistance += cityFrom . distanceTo ( cityTo , false ) ; if ( isCompleteTour ( ) ) record ( ) ; }
Add visited city to tour.
Add visited city to tour .