Function travelling_salesman::get_route_distance
[−]
[src]
pub fn get_route_distance(distance_matrix: &Vec<Vec<f64>>, route: &Vec<u32>) -> f64
Utility function to calculate the distance travelled following the specified route
Examples
extern crate travelling_salesman; use travelling_salesman::*; fn main() { let cities = vec![ (27.0, 78.0), (18.0, 24.0), (48.0, 62.0), (83.0, 17.0), ]; let distance_matrix = get_distance_matrix(&cities); let route_distance = get_route_distance(&distance_matrix, &vec![3, 0, 2, 1, 3]); assert!((route_distance - 222.998472).abs() < 0.000001); }