Table of Contents
Installation is pretty standard:
$ gem install travel_salesman
or with using Bundler, add this line to your Gemfile
gem 'travel_salesman'
Route start and end at first index of the 2D array. This 2D array is your distance matrix
distance_matrix = [
[0, 10, 15, 20],
[5, 0, 9, 10],
[6, 13, 0, 12],
[8, 8, 9, 0]
]
TravelSalesman.new(distance_matrix).get_tour_distance
# => 35
Route start and end at first index of the 2D array. This 2D array is your distance matrix
distance_matrix = [
[0, 10, 15, 20],
[5, 0, 9, 10],
[6, 13, 0, 12],
[8, 8, 9, 0]
]
puts TravelSalesman.new(distance_matrix).get_tour_route
# => [0, 1, 3, 2, 0]
People behind the 💻
Ata Günay |