pub fn dijkstra(&self) -> usize {
        let mut costs: HashMap<Point, usize> = HashMap::new();
        let mut heap = BinaryHeap::new();

        heap.push(((0, 0), 0));

        while let Some(pos) = heap.pop() {
            if self.end_pos() == pos.0 {
                continue;
            }

            if pos.1 <= *costs.get(&pos.0).unwrap_or(&usize::MAX) {
                for n in self.neighbors(pos.0) {
                    let new_cost = self.map[n.0 as usize][n.1 as usize] as usize + pos.1;

                    if new_cost < *costs.get(&n).unwrap_or(&usize::MAX) {
                        heap.push((n, new_cost));
                        costs.insert(n, new_cost);
                    }
                }
            }
        }

        *costs.get(&self.end_pos()).unwrap()
    }
/// Runs a dijkstra that checks all paths 
///
/// The return value will always be the cost of the smallest one
Runs a dijkstra that checks all paths
The return value will always be the cost of the smallest one
Runs a dijkstra that checks all paths The return value will always be the cost of the smallest one
pub fn dijkstra(&self) -> usize {
        let mut costs: HashMap<Point, usize> = HashMap::new();
        let mut heap = BinaryHeap::new();
        heap.push(((0, 0), 0));
        while let Some(pos) = heap.pop() {
            if self.end_pos() == pos.0 {
                continue;
            }
            if pos.1 <= *costs.get(&pos.0).unwrap_or(&usize::MAX) {
                for n in self.neighbors(pos.0) {
                    let new_cost = self.map[n.0 as usize][n.1 as usize] as usize + pos.1;
                    if new_cost < *costs.get(&n).unwrap_or(&usize::MAX) {
                        heap.push((n, new_cost));
                        costs.insert(n, new_cost);
                    }
                }
            }
        }
        *costs.get(&self.end_pos()).unwrap()
    }
pub fn dijkstra ( & self ) -> usize { let mut costs : HashMap < Point , usize > = HashMap :: new ( ) ; let mut heap = BinaryHeap :: new ( ) ; heap . push ( ( ( 0 , 0 ) , 0 ) ) ; while let Some ( pos ) = heap . pop ( ) { if self . end_pos ( ) == pos . 0 { continue ; } if pos . 1 <= * costs . get ( & pos . 0 ) . unwrap_or ( & usize :: MAX ) { for n in self . neighbors ( pos . 0 ) { let new_cost = self . map [ n . 0 as usize ] [ n . 1 as usize ] as usize + pos . 1 ; if new_cost < * costs . get ( & n ) . unwrap_or ( & usize :: MAX ) { heap . push ( ( n , new_cost ) ) ; costs . insert ( n , new_cost ) ; } } } } * costs . get ( & self . end_pos ( ) ) . unwrap ( ) }
Runs a dijkstra that checks all paths
The return value will always be the cost of the smallest one
Runs a dijkstra that checks all paths The return value will always be the cost of the smallest one
&self
&self