This is a build step rather than a repair. A cheap insertion pass followed by one refinement reaches a better graph, in less total time, than a single expensive insertion pass - so a wide refine.expansion_factor belongs here rather than in usearch_dense_insert.
Cancelling is safe, which is what makes a whole-graph sweep affordable. Re-selecting a node's neighbors is idempotent and claims no identity, so a stopped pass leaves the graph correct and merely less improved: nothing unwinds, and the call answers usearch_status_cancelled_k. The index keeps nothing of a stopped pass, so the next call starts at the first entry again; a caller wanting to continue where a cancel stopped holds a usearch_dense_refinement_t instead. A caller loops until the report's changed falls below whatever change rate they consider settled.
Re-selection alone can leave an island, an entry no search reaches, so every call closes by re-linking them: unreachable entries re-select from scratch, and whatever the diversity judgment still drops is reconnected to a reachable one. A cancelled call skips the rest of the re-selection but still re-links, so it never leaves entries unreachable.
On a RAM handle searches may run throughout: re-selection publishes one node at a time and never removes a node, so a concurrent walk sees either the old neighbors or the new ones. On a VRAM handle the merge writes neighbors in place, so searches may not overlap. Insertions never overlap: one in flight refuses the call with usearch_status_contended_k, and one arriving meanwhile is refused the same way, as is a VRAM save. A viewed handle refuses with usearch_status_read_only_k, like every other mutating verb.
This is a build step rather than a repair. A cheap insertion pass followed by one refinement reaches a better graph, in less total time, than a single expensive insertion pass - so a wide refine.expansion_factor belongs here rather than in usearch_geospatial_insert. A refined entry keeps its cone winners and the longest of its other candidates, then has its long links drawn again by the insertion's rule, so a refine never leaves an entry without them.
Cancelling is safe, which is what makes a whole-graph sweep affordable. Re-selecting an entry's neighbors is idempotent and claims no identity, so a stopped pass leaves the graph correct and merely less improved: nothing unwinds, and the call answers usearch_status_cancelled_k. The index keeps nothing of a stopped pass, so the next call starts at the first entry again; a caller wanting to continue where a cancel stopped holds a usearch_geospatial_refinement_t instead.
Re-selection alone can leave an island, an entry no search reaches, so every call closes by re-linking them: unreachable entries re-select from scratch, and whatever the selection still drops is reconnected to a reachable one. A cancelled call skips the rest of the re-selection but still re-links, so it never leaves entries unreachable.
Searches may run throughout: re-selection rewrites one entry at a time and never removes one, so a concurrent walk sees either the old neighbors or the new ones. Insertions never overlap: one in flight refuses the call with usearch_status_contended_k, and one arriving meanwhile is refused the same way, as is a save.
This is a build step rather than a repair. A cheap insertion pass followed by one refinement reaches a better graph, in less total time, than a single expensive insertion pass - so a wide refine.expansion_factor belongs here rather than in usearch_sequence_insert. It pays most in this modality, where a single alignment is quadratic and a stingy insertion pass is tempting.
Cancelling is safe, which is what makes a whole-graph sweep affordable. Re-selecting an entry's neighbors is idempotent and claims no identity, so a stopped pass leaves the graph correct and merely less improved: nothing unwinds, and the call answers usearch_status_cancelled_k. The index keeps nothing of a stopped pass, so the next call starts at the first entry again; a caller wanting to continue where a cancel stopped holds a usearch_sequence_refinement_t instead.
Re-selection alone can leave an island, an entry no search reaches, so every call closes by re-linking them: unreachable entries re-select from scratch, and whatever the selection still drops is reconnected to a reachable one. A cancelled call skips the rest of the re-selection but still re-links, so it never leaves entries unreachable.
Searches may run throughout: re-selection rewrites one entry at a time and never removes one, so a concurrent walk sees either the old neighbors or the new ones. Insertions never overlap: one in flight refuses the call with usearch_status_contended_k, and one arriving meanwhile is refused the same way, as is a save.
This is a build step rather than a repair. A cheap insertion pass followed by one refinement reaches a better graph, in less total time, than a single expensive insertion pass - so a wide refine.expansion_factor belongs here rather than in usearch_shapes_insert. It pays most in this modality, where one comparison scores a whole shape against another.
Cancelling is safe, which is what makes a whole-graph sweep affordable. Re-selecting an entry's neighbors is idempotent and claims no identity, so a stopped pass leaves the graph correct and merely less improved: nothing unwinds, and the call answers usearch_status_cancelled_k. The index keeps nothing of a stopped pass, so the next call starts at the first entry again; a caller wanting to continue where a cancel stopped holds a usearch_shapes_refinement_t instead.
Re-selection alone can leave an island, an entry no search reaches, so every call closes by re-linking them: unreachable entries re-select from scratch, and whatever the selection still drops is reconnected to a reachable one. A cancelled call skips the rest of the re-selection but still re-links, so it never leaves entries unreachable.
Searches may run throughout: re-selection rewrites one entry at a time and never removes one, so a concurrent walk sees either the old neighbors or the new ones. Insertions never overlap: one in flight refuses the call with usearch_status_contended_k, and one arriving meanwhile is refused the same way, as is a save.