mod neighbors

module neighbors

Incremental neighbour table shared across the hop. An incremental neighbour table shared across the hop.

Every kernel that reads structure recomputes it per call: surface relocation its coordination counts, the graph key its distances, ring profiles their adjacency. Each is O(n^2) per proposal, and a hop makes several proposals from the same incumbent. The measured-productive moves displace one to three atoms, so between incumbents the table changes in O(k n), not O(n^2): the blocked-kernel economy of the eigensolver libraries, applied to the structure every consumer shares.

The table is exact, not approximate: after any sequence of updates it equals the table built from scratch, and a test witnesses that on random configurations and random moves.

Structs and Unions

struct NeighborTable

Sorted adjacency lists under a fixed absolute cutoff.

Implementations

impl NeighborTable

Functions

fn build(x: ArrayView1<f64>, n: usize, cutoff: f64) -> Self

Builds the table from scratch in O(n^2).

fn degree(&self, i: usize) -> usize

Coordination of i.

fn is_empty(&self) -> bool

Whether the table is empty.

fn len(&self) -> usize

Points in the table.

fn moved_between(a: ArrayView1<f64>, b: ArrayView1<f64>) -> Vec<usize>

The atoms whose coordinates differ between two structures.

fn neighbors(&self, i: usize) -> &[usize]

Neighbours of i, sorted ascending.

fn update(&mut self, x_new: ArrayView1<f64>, moved: &[usize])

Reconciles the table with x_new after the atoms in moved changed, in O(k n) for k moved atoms.

Exactness rests on one fact: a pair’s distance changed only if at least one of its ends moved, so edges between unmoved atoms need no inspection.