Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

cut_tour

Cut a tour to form a path


Description

Cuts a tour at a specified city to form a path.

Usage

cut_tour(x, cut, exclude_cut = TRUE)

Arguments

x

an object of class TOUR.

cut

the index or label of the city/cities to cut the tour.

exclude_cut

exclude the city where we cut? If FALSE, the city at the cut is included in the path as the first city.

Value

Returns a named vector with city ids forming the path. If multiple cuts are used then a list with paths is returned.

Author(s)

Michael Hahsler

See Also

Examples

data("USCA50")

## find a path starting at Austin, TX
tour <- solve_TSP(USCA50)
path <- cut_tour(tour, cut = "Austin, TX", exclude_cut = FALSE)
path

## cut the tours at two cities
tour <- solve_TSP(USCA50)
path <- cut_tour(tour, cut = c("Austin, TX", "Cambridge, MA"), exclude_cut = FALSE)
path

## cut a tour at the largest gap using a dummy city
tsp <- insert_dummy(USCA50, label = "cut")
tour <- solve_TSP(tsp)

## cut tour into path at the dummy city
path <- cut_tour(tour, "cut")
path

TSP

Traveling Salesperson Problem (TSP)

v1.1-10
GPL-3
Authors
Michael Hahsler [aut, cre, cph], Kurt Hornik [aut, cph]
Initial release
2020-04-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.