Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
automainint committed Jul 22, 2024
1 parent d32136d commit d697d34
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 44 deletions.
12 changes: 6 additions & 6 deletions bench/test_smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1743,27 +1743,27 @@ mod tests {

println!("1");
rank.add_edge(3, 35, 0.6870330406793382);
assert!(get_time() < 5000);
assert!(get_time() < 10000);

println!("2");
rank.add_edge(3, 27, 0.6750305618933777);
assert!(get_time() < 5000);
assert!(get_time() < 10000);

println!("3");
rank.add_edge(3, 252, 0.6709551330130799);
assert!(get_time() < 5000);
assert!(get_time() < 10000);

println!("4");
rank.add_edge(3, 24, 0.6658611955039131);
assert!(get_time() < 5000);
assert!(get_time() < 10000);

println!("5");
rank.add_edge(3, 286, 0.6332146304754731);
assert!(get_time() < 5000);
assert!(get_time() < 10000);

println!("6");
rank.add_edge(3, 208, 0.6148736192067291);
assert!(get_time() < 5000);
assert!(get_time() < 10000);
}

#[test]
Expand Down
4 changes: 1 addition & 3 deletions src/graph.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::collections::HashMap;
use indexmap::IndexMap;
use integer_hasher::{BuildIntHasher, IntMap};
use integer_hasher::IntMap;

use log::error;
use rand::distributions::{Distribution, WeightedIndex};
Expand Down
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ fn main() {

let mut nodes: Vec<NodeId> = Vec::new();

for n in 0..5{
for _ in 0..5 {
nodes.push(graph.get_new_nodeid());

}

graph.add_edge(nodes[1], nodes[2], 0.98);
graph.add_edge(nodes[2], nodes[3], 1.0);
graph.add_edge(nodes[3], nodes[4], 1.0);
let _ = graph.add_edge(nodes[1], nodes[2], 0.98).unwrap();
let _ = graph.add_edge(nodes[2], nodes[3], 1.00).unwrap();
let _ = graph.add_edge(nodes[3], nodes[4], 1.00).unwrap();

// create merit rank
let mut newrank = match MeritRank::new(graph) {
Expand Down
8 changes: 4 additions & 4 deletions src/rank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl MeritRank {
let mut rng = thread_rng();

loop{
let mut node_data =self.graph.get_node_data_mut(node).unwrap();
let node_data = self.graph.get_node_data_mut(node).unwrap();
let neighbors = node_data
.neighbors(Neighbors::Positive);
if neighbors.is_empty() {
Expand Down Expand Up @@ -271,7 +271,7 @@ impl MeritRank {
}
}

fn assert_counters_consistency_after_edge_addition(&self, weight: f64) {
fn assert_counters_consistency_after_edge_addition(&self, _weight: f64) {
for (ego, hits) in &self.personal_hits {
for (peer, count) in hits {
let visits = self.walks.get_visits_through_node(*peer).unwrap();
Expand All @@ -286,7 +286,7 @@ impl MeritRank {
}

fn zn(&mut self, src: NodeId, dest: NodeId, weight: f64) {
self.graph.add_edge(src, dest, weight);
let _ = self.graph.add_edge(src, dest, weight);
self.update_penalties_for_edge(src, dest, false);
}

Expand All @@ -305,7 +305,7 @@ impl MeritRank {

fn nz(&mut self, src: NodeId, dest: NodeId, _weight: f64) {
self.update_penalties_for_edge(src, dest, true);
self.graph.remove_edge(src, dest);
let _ = self.graph.remove_edge(src, dest);
}
fn np(&mut self, src: NodeId, dest: NodeId, weight: f64) {
self.nz(src, dest, weight);
Expand Down
54 changes: 27 additions & 27 deletions tests/test_dumps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ mod tests {
complete_graph.get_new_nodeid();
}

complete_graph.add_edge(0, 1, w0_1);
complete_graph.add_edge(0, 2, w0_2);
complete_graph.add_edge(1, 0, w1_0);
complete_graph.add_edge(1, 2, w1_2);
complete_graph.add_edge(2, 0, w2_0);
complete_graph.add_edge(2, 1, w2_1);
let _ = complete_graph.add_edge(0, 1, w0_1);
let _ = complete_graph.add_edge(0, 2, w0_2);
let _ = complete_graph.add_edge(1, 0, w1_0);
let _ = complete_graph.add_edge(1, 2, w1_2);
let _ = complete_graph.add_edge(2, 0, w2_0);
let _ = complete_graph.add_edge(2, 1, w2_1);

let mut meritrank = MeritRank::new(complete_graph).unwrap();

Expand Down Expand Up @@ -210,22 +210,22 @@ mod tests {
let mut complete_graph = Graph::new();
let node_ids: Vec<NodeId> = vec![0, 1, 2, 3];

for node_id in &node_ids {
for _ in &node_ids {
complete_graph.get_new_nodeid();
}

complete_graph.add_edge(0, 1, w0_1);
complete_graph.add_edge(0, 2, w0_2);
complete_graph.add_edge(0, 3, w0_3);
complete_graph.add_edge(1, 0, w1_0);
complete_graph.add_edge(1, 2, w1_2);
complete_graph.add_edge(1, 3, w1_3);
complete_graph.add_edge(2, 0, w2_0);
complete_graph.add_edge(2, 1, w2_1);
complete_graph.add_edge(2, 3, w2_3);
complete_graph.add_edge(3, 0, w3_0);
complete_graph.add_edge(3, 1, w3_1);
complete_graph.add_edge(3, 2, w3_2);
let _ = complete_graph.add_edge(0, 1, w0_1);
let _ = complete_graph.add_edge(0, 2, w0_2);
let _ = complete_graph.add_edge(0, 3, w0_3);
let _ = complete_graph.add_edge(1, 0, w1_0);
let _ = complete_graph.add_edge(1, 2, w1_2);
let _ = complete_graph.add_edge(1, 3, w1_3);
let _ = complete_graph.add_edge(2, 0, w2_0);
let _ = complete_graph.add_edge(2, 1, w2_1);
let _ = complete_graph.add_edge(2, 3, w2_3);
let _ = complete_graph.add_edge(3, 0, w3_0);
let _ = complete_graph.add_edge(3, 1, w3_1);
let _ = complete_graph.add_edge(3, 2, w3_2);

let mut meritrank = MeritRank::new(complete_graph).unwrap();

Expand Down Expand Up @@ -313,12 +313,12 @@ mod tests {
.collect::<Result<Vec<_>, _>>()?
.try_into()?;

graph.add_edge(0, 1, weights[0]);
graph.add_edge(0, 2, weights[1]);
graph.add_edge(1, 0, weights[2]);
graph.add_edge(1, 2, weights[3]);
graph.add_edge(2, 0, weights[4]);
graph.add_edge(2, 1, weights[5]);
let _ = graph.add_edge(0, 1, weights[0]);
let _ = graph.add_edge(0, 2, weights[1]);
let _ = graph.add_edge(1, 0, weights[2]);
let _ = graph.add_edge(1, 2, weights[3]);
let _ = graph.add_edge(2, 0, weights[4]);
let _ = graph.add_edge(2, 1, weights[5]);

meritrank_opt = Some(MeritRank::new(graph)?);
meritrank_opt.as_mut().unwrap().calculate(0, 20000)?;
Expand Down Expand Up @@ -391,7 +391,7 @@ mod tests {
let mut graph = Graph::new();
let node_ids: Vec<NodeId> = vec![0, 1, 2, 3];

for &node_id in &node_ids {
for _ in &node_ids {
graph.get_new_nodeid();
}

Expand All @@ -411,7 +411,7 @@ mod tests {
];

for (i, &(src, dest)) in edges.iter().enumerate() {
graph.add_edge(src, dest, weights[i]);
let _ = graph.add_edge(src, dest, weights[i]);
}

meritrank_opt = Some(MeritRank::new(graph)?);
Expand Down

0 comments on commit d697d34

Please sign in to comment.