Skip to main content

reduce_nary

Function reduce_nary 

Source
pub fn reduce_nary(coverage: &[(u32, u32)], k: u32) -> Vec<KeptNaryPattern>
Expand description

Reduce per-pattern (positives_covered, negatives_covered) counts to the final ordered top-K.

The binary reduction law with the topology dimension removed and the canonical enumeration index as the final tie-breaker:

  1. Sort pattern indexes by (-positives_covered, negatives_covered, pattern_idx). The enumeration is deterministic lexicographic, so the index tie-break is as stable across calls as the binary engine’s (left_idx, right_idx) tie-break.
  2. Filter to positives_covered > 0, keep the first k.
  3. local_rank / next_* over the positive-filtered list; tie_class_size over the FULL batch (including zero-coverage).