set.seed(1)
n <- 25
z <- cbind(runif(n,min=1,max=10),runif(n,min=1,max=10))
d <- compute_distance_matrix(z)
h <- sample(1:n) # A random tour
compute_path_distance(h, d) # 107.246
compute_tour_distance(h, d) - compute_path_distance(h, d) - d[h[1], h[n]]
Run the code above in your browser using DataLab