Skip to content

Commit

Permalink
Fix counter underflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ichorid committed Oct 5, 2024
1 parent efc336f commit 5fad694
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/rank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ impl MeritRank {
let default_counter = Counter::default();

let ego_neg_hits = self.neg_hits.get(&ego).unwrap_or(&default_counter);
let hits_penalized = hits - ego_neg_hits.get_count(&target);
Ok(hits_penalized as Weight / counter.total_count() as Weight)
let hits_penalized: Weight = hits as Weight - ego_neg_hits.get_count(&target) as Weight;
Ok(hits_penalized / counter.total_count() as Weight)
}

pub fn get_ranks(&self, ego: NodeId, limit: Option<usize>) -> Result<Vec<(NodeId, Weight)>, MeritRankError> {
Expand Down

0 comments on commit 5fad694

Please sign in to comment.