tests/testthat/test-ETSP.R

library(TSP)
library(testthat)

context("ETSP")

x <- data.frame(x = runif(20), y = runif(20), row.names = LETTERS[1:20])

## create a TSP
etsp <- ETSP(x)
etsp

## use some methods
expect_equal(n_of_cities(etsp), 20L)
expect_equal(labels(etsp), LETTERS[1:20])

## plot ETSP and solution
tour <- solve_TSP(etsp)
tour

## compare tour_length
expect_equal(tour_length(etsp), tour_length(as.TSP(etsp)))
expect_equal(tour_length(tour, etsp), tour_length(tour, as.TSP(etsp)))

Try the TSP package in your browser

Any scripts or data that you put into this service are public.

TSP documentation built on April 30, 2018, 5:03 p.m.