Skip to main content

HyperbolicHashTable

Struct HyperbolicHashTable 

Source
pub struct HyperbolicHashTable { /* private fields */ }
Expand description

Hyperbolic Hash Table for O(1) lookups in hyperbolic space.

Buckets partition the Poincaré disk into ~61 fixed regions. Each bucket contains a VP-tree that provides O(log n) spatial queries within the bucket. Combined with the O(1) bucket selection, total query time is O(log(n/B)) where B is the bucket count.

Implementations§

Source§

impl HyperbolicHashTable

Source

pub fn new(dimension: usize) -> Self

Create a new hyperbolic hash table with the specified dimension.

Source

pub fn find_bucket(&self, point: &HyperbolicPoint) -> Option<String>

Find the bucket containing a point.

Uses a three-pass strategy:

  1. Exact signature match (O(1) HashMap lookup)
  2. Euclidean-distance prefilter: sort buckets by cheap Euclidean² distance to their center, then check hyperbolic containment starting from the nearest. Typically finds the match in 1-3 checks (~20-60µs) instead of scanning all ~61 buckets (~1.2ms).
  3. quick_validate fallback for edge cases.
Source

pub fn create_signature( &self, point: &HyperbolicPoint, level: u32, ) -> Option<GeometricSignature>

Create a geometric signature for a point.

Uses the point’s actual coordinates for the position signature (not the bucket center), ensuring unique signatures for distinct points even when they fall in the same geometric bucket. The hash field identifies the bucket for O(1) locality lookup.

Source

pub fn validate_point(&self, point: &HyperbolicPoint) -> bool

Check if a hyperbolic point is valid.

Source

pub fn poincare_disk(&self) -> &PoincareDisk

Get the Poincaré disk.

Source

pub fn bucket_count(&self) -> usize

Get the number of buckets.

Source

pub fn register_node( &self, point: &HyperbolicPoint, unique_id: &str, level: u32, ) -> Option<String>

Register a node in the spatial index. Returns the bucket hash the node was placed in.

Source

pub fn register_node_with_hint( &self, point: &HyperbolicPoint, unique_id: &str, level: u32, bucket_hint: Option<&str>, ) -> Option<String>

Register a node in the spatial index with an optional bucket hash hint.

When bucket_hint is provided (e.g. from a prior create_signature call), skips the expensive find_bucket lookup entirely. Falls back to find_bucket if the hint is invalid.

Source

pub fn unregister_node(&self, unique_id: &str)

Remove a node from the spatial index. O(1) via node_to_bucket reverse map — only touches the correct bucket.

Source

pub fn find_nodes_in_radius( &self, center: &HyperbolicPoint, radius: FixedPoint, ) -> Vec<(String, FixedPoint)>

Find all nodes within a hyperbolic radius of a center point.

  1. Quick-reject entire buckets whose centers are beyond radius + bucket_radius.
  2. Within each candidate bucket, use the VP-tree’s O(log n) range query.
Source

pub fn find_nearest_nodes( &self, point: &HyperbolicPoint, k: usize, ) -> Vec<(String, FixedPoint)>

Find the k nearest nodes to a point.

Sorts buckets by distance to query point, queries each bucket’s VP-tree for its k-nearest, and merges results with proper early termination: stops when the next bucket’s minimum possible distance exceeds the k-th candidate’s distance.

Source

pub fn verify_integrity(&self) -> bool

Verify the integrity of the hash table.

Trait Implementations§

Source§

impl Clone for HyperbolicHashTable

Source§

fn clone(&self) -> HyperbolicHashTable

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HyperbolicHashTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.