Skip to main content

collect_capped_edges

Function collect_capped_edges 

Source
pub fn collect_capped_edges(
    fragments: &[Fragment],
    repo_root: Option<&Path>,
    skip_expensive: bool,
) -> CappedEdges
Expand description

Two-pass edge construction that never retains the raw edge universe as keyed dictionaries and runs every builder exactly once.

Pass 1 runs every builder and records its emissions into a compact per-builder log of (src, dst, weight) triples (16 bytes/edge, builder tag implicit in the outer index); a first-seen scan in builder registration order reproduces dedup_compact_edges semantics exactly (each pair counted once, category from the first builder that produced it) and yields per-node in-degree, per-source out-degree, the semantic distinct-file fan counts, and a sorted (src, dst) -> category lookup used only internally by pass 2 (below) — it is not returned to the caller; assemble_graph derives the exported category table from the post-cap edges instead, which is what keeps it aligned with the CSR (see graph::assemble_graph).

Pass 2 replays the log instead of rerunning the builders, damps each emission on the fly with the pass-1 hub-suppression factors — always under the pair’s canonical first-builder category — and keeps at most K candidates per source per builder in a bounded min-heap, freeing each builder’s log shard as it is consumed. Any edge evicted from a per-builder heap is outranked by K surviving same-source edges, so the final merge + dedup + cap over the survivors is bit-identical to capping the full materialized universe.