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)
| 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. |