        node_index: usize,
    ) -> &'result mut WeightType {
        let key = ToOwnedUsize { value: node_index };
        self.entry_ref(&key)
            .or_insert_with(|| WeightType::infinity())
    }

    fn set(&mut self, node_index: usize, weight: WeightType) {
        let key = ToOwnedUsize { value: node_index };
        self.insert(key, weight);
    }
