Edit edges

This commit is contained in:
2022-05-10 15:22:48 -05:00
parent 5bb5e09901
commit f699cc61e3
4 changed files with 25 additions and 4 deletions

View File

@@ -43,6 +43,11 @@ impl Board {
}
}
pub fn add_edge(&mut self, from: usize, to: usize) {
let node = self.nodes.get_mut(&from).expect("Could not find node");
node.edges.insert(to);
}
pub fn nearest_node(&self, x: f32, y: f32) -> Option<usize> {
let f = |n: &Node| dist_sq((n.x, n.y), (x, y));
let mut iter = self.nodes.iter();