Learn R Programming

TSP (version 0.1-2)

tour_length: Calculate the length of a tour

Description

Calculate the length of a tour given a TSP and an order.

Usage

tour_length(x, order)

Arguments

x
an object of class TSP.
order
optional order of the visited cities as a integer vector or an object of class TOUR. If no order is given, the cities are visited in the original order in x.

See Also

TSP, TOUR.

Examples

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

## original order
tour_length(tsp)

## random tour
tour_length(tsp, sample(1:n_of_cities(tsp)))

Run the code above in your browser using DataLab