Constructor to create an instance of a symmetric traveling salesperson problem (TSP) and some auxiliary methods.
## constructor TSP(x, labels = NULL)## coercion as.TSP(x)## methods # S3 method for TSP n_of_cities(x) # S3 method for TSP image(x, order, col = gray.colors(64), …) # S3 method for TSP labels(object, …) # S3 method for TSP print(x, …)
## coercion as.TSP(x)
## methods # S3 method for TSP n_of_cities(x) # S3 method for TSP image(x, order, col = gray.colors(64), …) # S3 method for TSP labels(object, …) # S3 method for TSP print(x, …)
an object (currently dist or a symmetric matrix) to be converted into a TSP or, for the methods, an object of class TSP.
dist
TSP
optional city labels. If not given, labels are taken from x.
x
color scheme for image.
order of cities for the image as an integer vector or an object of class TOUR.
TOUR
further arguments are passed on.
TSP() returns x as an object of class TSP.
TSP()
n_of_cities() returns the number of cities in x.
n_of_cities()
labels() returns a vector with the names of the cities in x.
labels()
Objects of class TSP are internally represented as dist objects (use as.dist() to get the dist object).
as.dist()
TOUR, insert_dummy, tour_length, solve_TSP.
insert_dummy
tour_length
solve_TSP
# NOT RUN { data("iris") d <- dist(iris[-5]) ## create a TSP tsp <- TSP(d) tsp ## use some methods n_of_cities(tsp) labels(tsp) image(tsp) # }
Run the code above in your browser using DataLab