diff --git a/src/belt_finding/mod.rs b/src/belt_finding/mod.rs index 2b3fec0..a216877 100644 --- a/src/belt_finding/mod.rs +++ b/src/belt_finding/mod.rs @@ -156,50 +156,6 @@ struct MapInternal<'a> { impl<'a> WheightedGraph for MapInternal<'a> { type Node = (Position, Direction); - fn num_edges(&self, node: &Self::Node) -> usize { - todo!(); - // let next = node.0.in_direction(&node.1, 1); - // if next - // .in_range( - // &Position::new(0, 0), - // &Position::new( - // self.map.width as PositionType, - // self.map.height as PositionType, - // ), - // ) - // .is_some() - // { - // return 0; - // } - - // if self.map.get(next.x as usize, next.y as usize).blocked { - // return 0; - // } - - // let mut count = 3; - - // for l in 2..=6 { - // let n = node.0.in_direction(&node.1, l); - // dbg!(n, l); - // if n.in_range( - // &Position::new(0, 0), - // &Position::new( - // self.map.width as PositionType, - // self.map.height as PositionType, - // ), - // ) - // .is_some() - // { - // return count; - // } - // if !self.map.get(n.x as usize, n.y as usize).blocked { - // count += 1; - // } - // } - - // count - } - fn edge(&self, node: &Self::Node, num: usize) -> Option<(Self::Node, f64)> { let next = node.0.in_direction(&node.1, 1); if next diff --git a/src/graph/wheighted_graph/mod.rs b/src/graph/wheighted_graph/mod.rs index a27e5e3..86e8800 100644 --- a/src/graph/wheighted_graph/mod.rs +++ b/src/graph/wheighted_graph/mod.rs @@ -3,7 +3,10 @@ pub mod shortest_path; pub trait WheightedGraph: Sized { type Node; - fn num_edges(&self, node: &Self::Node) -> usize; + fn num_edges(&self, node: &Self::Node) -> usize { + self.edge_iter(node).count() + } + fn edge(&self, node: &Self::Node, num: usize) -> Option<(Self::Node, f64)>; fn edge_iter<'a, 'b>(&'a self, node: &'b Self::Node) -> WheightedGraphEdgeIter<'a, 'b, Self> {