Skip to content

Commit

Permalink
Update assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
automainint committed Jun 10, 2024
1 parent 5c17e32 commit ac84f1f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ where
{
let x: f64 = x.into();

if x >= EPSILON {
if x > EPSILON {
return 1;
} else if x <= -EPSILON {
} else if x < -EPSILON {
return -1;
}
return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/poswalk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use crate::random_walk::RandomWalk;

/// Represents a positional random walk.
pub struct PosWalk {
walk: RandomWalk,
pos: usize,
pub walk : RandomWalk,
pos : usize,
}

#[allow(dead_code)]
Expand Down
4 changes: 2 additions & 2 deletions src/random_walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::walk::{WalkId, WalkIdGenerator};
/// Represents a random walk through a graph.
#[derive(Clone)]
pub struct RandomWalk {
nodes: Vec<NodeId>,
walk_id: WalkId,
pub nodes : Vec<NodeId>,
walk_id : WalkId,
}

impl RandomWalk {
Expand Down
12 changes: 5 additions & 7 deletions src/rank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ impl MeritRank {
}
}

if weight > -EPSILON && weight < EPSILON {
if weight >= -EPSILON && weight <= EPSILON {
if self.graph.contains_edge(src, dest) {
self.graph.remove_edge(src, dest);
}
Expand All @@ -764,7 +764,7 @@ impl MeritRank {
let _ = self.recalc_invalidated_walk(
walk_mut,
force_first_step,
OPTIMIZE_INVALIDATION && weight == 0.0,
OPTIMIZE_INVALIDATION && weight >= -EPSILON && weight <= EPSILON,
);

if let Some(negs) = negs_cache.get_mut(&first_node) {
Expand All @@ -785,11 +785,9 @@ impl MeritRank {
if ASSERT {
for (ego, hits) in &self.personal_hits {
for (peer, count) in hits {
let walks = self.walks.get_walks_through_node(*peer, |_| true);
if walks.len() != *count as usize {
assert!(false);
}
if *count > 0.0 && weight > 0.0 && !self.graph.is_connecting(*ego, *peer) {
let walks = self.walks.get_walks_through_node(*peer, |x| x.walk.nodes[0] == *ego);
assert_eq!(walks.len(), *count as usize);
if *count > 0.0 && weight > EPSILON && !self.graph.is_connecting(*ego, *peer) {
assert!(false);
}
}
Expand Down

0 comments on commit ac84f1f

Please sign in to comment.