Learn R Programming

TSP (version 0.1-2)

TOUR: Class TOUR -- Solution to a traveling salesperson problem

Description

Class to store the solution of a TSP. Essentially, an object of class TOUR is an integer vector containing the order of cities to visit.

Usage

## S3 method for class 'TOUR':
print(x, \ldots)

Arguments

x
an object of class TOUR
...
further arguments are passed on.

Details

Since an object of class TOUR is an integer vector, it can be subsetted as an ordinary vector or coerced to vector using as.vector. Additionally, TOUR has the following attributes: "method", "tour_length".

For most functions, e.g., tour_length or image, the TSP object used to find the tour is still needed, since the tour does not contain the distance information.

See Also

TSP, tour_length, image.

Examples

Run this code
data("iris")
tsp <- TSP(dist(iris[1:4]))

## calculate a tour
tour <- solve_TSP(tsp)
tour

str(tour)

Run the code above in your browser using DataLab