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
impl HyperbolicHashTable
Sourcepub fn new(dimension: usize) -> Self
pub fn new(dimension: usize) -> Self
Create a new hyperbolic hash table with the specified dimension.
Sourcepub fn find_bucket(&self, point: &HyperbolicPoint) -> Option<String>
pub fn find_bucket(&self, point: &HyperbolicPoint) -> Option<String>
Find the bucket containing a point.
Uses a three-pass strategy:
- Exact signature match (O(1) HashMap lookup)
- 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).
- quick_validate fallback for edge cases.
Sourcepub fn create_signature(
&self,
point: &HyperbolicPoint,
level: u32,
) -> Option<GeometricSignature>
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.
Sourcepub fn validate_point(&self, point: &HyperbolicPoint) -> bool
pub fn validate_point(&self, point: &HyperbolicPoint) -> bool
Check if a hyperbolic point is valid.
Sourcepub fn poincare_disk(&self) -> &PoincareDisk
pub fn poincare_disk(&self) -> &PoincareDisk
Get the Poincaré disk.
Sourcepub fn bucket_count(&self) -> usize
pub fn bucket_count(&self) -> usize
Get the number of buckets.
Sourcepub fn register_node(
&self,
point: &HyperbolicPoint,
unique_id: &str,
level: u32,
) -> Option<String>
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.
Sourcepub fn register_node_with_hint(
&self,
point: &HyperbolicPoint,
unique_id: &str,
level: u32,
bucket_hint: Option<&str>,
) -> Option<String>
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.
Sourcepub fn unregister_node(&self, unique_id: &str)
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.
Sourcepub fn find_nodes_in_radius(
&self,
center: &HyperbolicPoint,
radius: FixedPoint,
) -> Vec<(String, FixedPoint)>
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.
- Quick-reject entire buckets whose centers are beyond radius + bucket_radius.
- Within each candidate bucket, use the VP-tree’s O(log n) range query.
Sourcepub fn find_nearest_nodes(
&self,
point: &HyperbolicPoint,
k: usize,
) -> Vec<(String, FixedPoint)>
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.
Sourcepub fn verify_integrity(&self) -> bool
pub fn verify_integrity(&self) -> bool
Verify the integrity of the hash table.
Trait Implementations§
Source§impl Clone for HyperbolicHashTable
impl Clone for HyperbolicHashTable
Source§fn clone(&self) -> HyperbolicHashTable
fn clone(&self) -> HyperbolicHashTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more