Feature/rstar fast#6
Open
ms609 wants to merge 3 commits into
Open
Conversation
Replace the dense O(n^3) triplet tensor (the hard 200-leaf MEMORY cap) and the
O(n^4) strong-cluster assembly in src/rstar.cpp with a tensor-free construction
that keeps the validated pipeline of Jansson, Sung, Vu & Yiu (2016): similarity
-> single-linkage (Apresjan) candidates -> filter-to-strong -> build.
* Stage 0: per-tree constant-time LCA (Euler tour + sparse-table RMQ), stored as
a pair-major O(kn^2) depth table -- no n^3 structure.
* Stage 1: tally the strict-plurality winner per triple into the n^2 similarity
s(a,b) = #{x : ab|x in R_maj}. O(kn^3) time, O(n^2) memory.
* Stage 2: maximum-spanning-tree single-linkage dendrogram of s yields a laminar
superset of the strong clusters; filter bottom-up while building the R* forest,
testing only new cross-block pairs and counting the smaller of inside/outside
leaves (deriving the other via s).
The R* tree is unchanged -- verified three ways: new-vs-old clade-for-clade on a
216-cell grid to n=200 (dev/oracle/rstar/check-vs-legacy.R, new regression
oracle), the brute-force strong-cluster oracle (0 mismatches), and the four
property pillars (identity, congruent==aho-build, strict & majority refinement).
Full testthat suite green (289 pass).
Memory is now O(kn^2), so the hard cap is gone: n=300 ~0.2s, n=500 ~0.7s at k=10
(formerly an immediate error). At n<=200 timing is at parity with the former
code (the tally stays O(kn^3); the paper sub-cubic bounds are galactic -- BMM /
dynamic-connectivity machinery slower than naive for every feasible n -- so they
are deliberately not used).
R/rstar.R drops the n>200 guard and updates @details; tests swap the cap-error
case for large-n success + refinement checks; the R* oracle scripts honour a
CONSTREE_LIB isolated-library override; bench cap raised. RcppExports unchanged
(rStarConsensus signature stable).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Mark the unreachable defensive paths in src/rstar.cpp with `// # nocov` (the k*n^2 memory guard, the n<3 direct-call guard, the small-n LCA self-check stop, and closePair's fall-through return) so codecov does not flag them as uncovered new lines. Add Apresjan and LCA to inst/WORDLIST (spell_check_package). No behaviour change; all gates re-verified green on the rebuilt package (four pillars, new-vs-old 216/216, brute-force strong-cluster oracle, full testthat suite 289 pass). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6 +/- ##
==========================================
+ Coverage 99.06% 99.07% +0.01%
==========================================
Files 18 18
Lines 2879 2933 +54
==========================================
+ Hits 2852 2906 +54
Misses 27 27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.