TSP

0th

Percentile

Class TSP -- Symmetric traveling salesperson problem

Constructor to create an instance of a symmetric traveling salesperson problem (TSP) and some auxiliary methods.

Keywords
classes
Usage
## constructor TSP(x, labels = NULL)
## coercion as.TSP(x)
## methods "n_of_cities"(x) "image"(x, order, col = gray.colors(64), ...) "labels"(object, ...) "print"(x, ...)
Arguments
x, object
an object (currently dist or a symmetric matrix) to be converted into a TSP or, for the methods, an object of class TSP.
labels
optional city labels. If not given, labels are taken from x.
col
color scheme for image.
order
order of cities for the image as an integer vector or an object of class TOUR.
...
further arguments are passed on.
Details

Objects of class TSP are internally represented as dist objects (use as.dist() to get the dist object).

Value

TSP() returns x as an object of class TSP.n_of_cities() returns the number of cities in x.labels() returns a vector with the names of the cities in x.

See Also

TOUR, insert_dummy, tour_length, solve_TSP.

Aliases
  • TSP
  • as.TSP
  • as.TSP.matrix
  • as.TSP.dist
  • n_of_cities
  • n_of_cities.TSP
  • print.TSP
  • labels.TSP
  • image.TSP
Examples
data("iris")
d <- dist(iris[-5])

## create a TSP
tsp <- TSP(d)
tsp

## use some methods 
n_of_cities(tsp)
labels(tsp)
image(tsp)
Documentation reproduced from package TSP, version 1.1-4, License: GPL-3

Community examples

Looks like there are no examples yet.