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

Method label_edge_count

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

Get the edge count for a specific label. O(E) unless cached. Returns 0 if the label doesn't exist.

(&self, label: &str)

Source from the content-addressed store, hash-verified

160 ///
161 /// Returns 0 if the label doesn't exist.
162 pub fn label_edge_count(&self, label: &str) -> usize {
163 let Some(lid) = self.label_id(label) else {
164 return 0;
165 };
166
167 let n = self.node_count();
168 let mut count = 0usize;
169 for node in 0..n {
170 for (l, _dst) in self.dense_iter_out(node as u32) {
171 if l == lid {
172 count += 1;
173 }
174 }
175 }
176 count
177 }
178
179 /// Estimate the selectivity of a label: edge_count / total_edges.
180 ///

Callers 2

label_selectivityMethod · 0.80
score_tripleFunction · 0.80

Calls 3

dense_iter_outMethod · 0.80
label_idMethod · 0.45
node_countMethod · 0.45

Tested by

no test coverage detected