tsp_rs/point.rs
1use crate::Metrizable;
2
3#[derive(Debug, Clone, PartialEq, PartialOrd)]
4pub struct Point {
5 x: f64,
6 y: f64,
7}
8
9impl Point {
10 pub fn new(x: f64, y: f64) -> Point {
11 Point { x, y }
12 }
13}
14
15impl Metrizable for Point {
16 fn cost(&self, other: &Point) -> f64 {
17 return ((self.x - other.x).powf(2.) + (self.y - other.y).powf(2.)).sqrt();
18 }
19}