data("USCA312")
## calculate a tour
tour <- solve_TSP(USCA312)
tour
# Visualize the tour if package maps is installed
if(require("maps")) {
library(maps)
data("USCA312_GPS")
head(USCA312_GPS)
plot((USCA312_GPS[, c("long", "lat")]), cex = .3)
map("world", col = "gray", add = TRUE)
polygon(USCA312_GPS[, c("long", "lat")][tour,], border = "red")
}
Run the code above in your browser using DataLab