MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / label_selectivity

Method label_selectivity

nodedb-graph/src/csr/statistics.rs:183–193  ·  view source on GitHub ↗

Estimate the selectivity of a label: edge_count / total_edges. Returns 1.0 for unknown labels (conservative — assume all edges). Returns 0.0 for graphs with no edges.

(&self, label: &str)

Source from the content-addressed store, hash-verified

181 /// Returns 1.0 for unknown labels (conservative — assume all edges).
182 /// Returns 0.0 for graphs with no edges.
183 pub fn label_selectivity(&self, label: &str) -> f64 {
184 let total = self.edge_count();
185 if total == 0 {
186 return 0.0;
187 }
188 let count = self.label_edge_count(label);
189 if count == 0 {
190 return 1.0; // Unknown label → conservative estimate.
191 }
192 count as f64 / total as f64
193 }
194}
195
196/// Compute degree distribution histogram from a degree array.

Callers 1

label_selectivity_valuesFunction · 0.80

Calls 2

label_edge_countMethod · 0.80
edge_countMethod · 0.45

Tested by 1

label_selectivity_valuesFunction · 0.64