Skip to content

MINGLE: O(E log E) via vendored nanoflann kd-tree - #26

Merged
schochastics merged 1 commit into
mainfrom
mingle-nanoflann
Jul 24, 2026
Merged

schochastics merged 1 commit into
mainfrom
mingle-nanoflann

Conversation

@schochastics

Copy link
Copy Markdown
Owner

Follow-up to Phase 6 (#24): make MINGLE scale near-linearly, as the paper intends.

What

  • Vendored src/nanoflann.hpp — a header-only kd-tree (nanoflann 1.10.1, BSD). No DESCRIPTION dependency (LinkingTo not needed; it's a self-contained header). Copyright holder added to Authors@R as cph; the BSD header is kept intact.
  • mingle_iter rewritten: build the kNN proximity graph over the edges (points in canonical 4-D endpoint space) once with the kd-tree, then coarsen that candidate graph combinatorially each level — instead of the previous O(E²) all-pairs rescan per level. Overall O(E log E).
  • New k argument on edge_bundle_mingle() (merge candidates per edge, default 10).

Behaviour preservation

The merge criterion is unchanged (nearest candidate by meeting-point distance → greedy ink-reducing match). With k ≥ edge count the candidate graph is complete, so merges are identical to the exhaustive version — the Phase-6 tests pass unchanged (small-graph mid-spread still 0.5).

Verification

  • Full suite FAIL 0 | PASS 82.
  • Small graph output identical to the brute-force version.
  • 300-edge random graph bundles in ~0.01s; k=3 and k=all both run and produce finite output.

🤖 Generated with Claude Code

Build the kNN proximity graph over edges once with a kd-tree (vendored
header-only nanoflann, BSD) instead of scanning all pairs, then coarsen
that candidate graph combinatorially level by level. Adds a `k` parameter
(merge candidates per edge). With k >= edge count the merges are identical
to the previous exhaustive search, so behaviour on small graphs is
unchanged; large graphs now scale near-linearly.

nanoflann's copyright holder added to Authors@R (cph); its BSD license
header is retained in src/nanoflann.hpp.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@schochastics
schochastics merged commit ff0e076 into main Jul 24, 2026
@schochastics
schochastics deleted the mingle-nanoflann branch July 24, 2026 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant