Crates.io | concorde_rs |
lib.rs | concorde_rs |
version | 0.1.1 |
source | src |
created_at | 2023-10-19 15:41:10.294018 |
updated_at | 2023-10-25 14:38:14.545861 |
description | A Rust binding to Concorde TSP Solver |
homepage | |
repository | https://github.com/equalis3r/concorde-rs |
max_upload_size | |
id | 1007924 |
size | 461,637 |
A Rust binding to Concorde TSP Solver that allows for directly calling the solver instead of communicating the problem via TSP.lib file. At the moment, this package only supports the call to two routines of the Concorde TSP Solver:
use concorde_rs::{solver, Distance, LowerDistanceMatrix};
fn main() {
struct Node(i32, i32);
impl Distance for Node {
fn calc_shortest_dist(&self, other: &Self) -> u32 {
self.0.abs_diff(other.0) + self.1.abs_diff(other.1)
}
}
let nodes: Vec<Node> = vec![Node(0, 0), Node(0, 3), Node(5, 6), Node(9, 1)];
let dist_mat = LowerDistanceMatrix::from(nodes.as_ref());
let solution = solver::tsp_hk(&dist_mat).unwrap();
assert_eq!(solution.length, 30);
}
The Rust binding code is licensed under MIT license. For the Concorde TSP Solver code, please check Concorde TSP Solver.