Skip to content

web search done right

respect max distance in distributed approx harmonic

Mikkel Denker127e1211b049
diff --git a/crates/core/src/entrypoint/ampc/approximated_harmonic_centrality/mapper.rs b/crates/core/src/entrypoint/ampc/approximated_harmonic_centrality/mapper.rs
index 831bc987..912b3ac2 100644
--- a/crates/core/src/entrypoint/ampc/approximated_harmonic_centrality/mapper.rs
+++ b/crates/core/src/entrypoint/ampc/approximated_harmonic_centrality/mapper.rs
@@ -132,7 +132,7 @@ impl Workers {
if dist < *cur_dist {
distances.insert(node, dist);
- if dist <= max_dist {
+ if dist < max_dist {
queue.push(cmp::Reverse((dist, node)));
}
}
@@ -146,7 +146,10 @@ impl Workers {
if dist < *cur_dist {
distances.insert(node, dist);
- queue.push(cmp::Reverse((dist, node)));
+
+ if dist < max_dist {
+ queue.push(cmp::Reverse((dist, node)));
+ }
}
}
}
diff --git a/crates/core/src/main.rs b/crates/core/src/main.rs
index 64a1b497..1564ff40 100644
--- a/crates/core/src/main.rs
+++ b/crates/core/src/main.rs
@@ -146,7 +146,8 @@ enum AmpcOptions {
HarmonicCoordinator { config_path: String },
/// Start a worker to compute an approximation of the harmonic centrality of a graph.
- /// The approximation samples a subset of the graph and computes shortest paths from the sampled nodes.
+ /// The approximation samples O(log n / sample_rate^2) nodes from the graph and computes
+ /// shortest paths from the sampled nodes.
ApproxHarmonicWorker { config_path: String },
/// Start a coordinator to distribute the approximation of the harmonic centrality computation.
diff --git a/crates/core/src/webgraph/centrality/approx_harmonic.rs b/crates/core/src/webgraph/centrality/approx_harmonic.rs
index 8f309365..b22a3245 100644
--- a/crates/core/src/webgraph/centrality/approx_harmonic.rs
+++ b/crates/core/src/webgraph/centrality/approx_harmonic.rs
@@ -22,12 +22,12 @@ use rayon::prelude::*;
use crate::webgraph::{NodeID, ShortestPaths, Webgraph};
-const EPSILON: f64 = 0.05;
+const EPSILON: f64 = 0.3;
// Approximate harmonic centrality by sampling O(log n / epsilon^2) nodes and
// computing single-source shortest paths from each of them.
//
-// Epsilong is set to 0.05.
+// Epsilong is set to 0.3.
pub struct ApproxHarmonic {
inner: speedy_kv::Db<NodeID, f64>,
}
@@ -49,7 +49,7 @@ impl ApproxHarmonic {
let norm = num_nodes as f32 / (num_samples as f32 * (num_nodes as f32 - 1.0));
sampled.into_par_iter().progress().for_each(|source| {
- let dists = graph.raw_distances_with_max(source, 5);
+ let dists = graph.raw_distances_with_max(source, 7);
for (target, dist) in dists {
if dist == 0 {