Skip to main content

CCHOneToMany

Struct CCHOneToMany 

Source
pub struct CCHOneToMany<'a> { /* private fields */ }
Expand description

A reusable one-to-many query with a fixed (pinned) set of targets.

Pinning precomputes the search space of the targets once; afterwards each CCHOneToMany::distances_from call answers distances from a source to all pinned targets in a single elimination-tree sweep, which is much faster than running one point-to-point query per target. Use this for distance tables / matrices (one CCHOneToMany per row) or k-nearest style workloads.

Thread-safety: Send but not Sync; holds mutable per-query state.

Implementations§

Source§

impl<'a> CCHOneToMany<'a>

Source

pub fn new(metric: &'a CCHMetric<'a>, targets: &[u32]) -> Self

Create a one-to-many query bound to metric with a fixed set of pinned targets. Distances returned later are aligned with the order of targets (duplicates are allowed and answered per entry).

Panics if any target node id is out of range.

Source

pub fn target_count(&self) -> usize

Number of pinned targets (= length of the distance vectors returned).

Source

pub fn repin_targets(&mut self, targets: &[u32])

Replace the pinned target set, reusing the query’s internal O(n) label buffers (cheaper than constructing a new CCHOneToMany).

Panics if any target node id is out of range.

Source

pub fn distances_from(&mut self, source: u32) -> Vec<Option<u32>>

Compute the shortest distances from source to every pinned target. Result is aligned with the pinned target order; None = unreachable.

Source

pub fn distances_from_multi( &mut self, sources: &[(u32, u32)], ) -> Vec<Option<u32>>

Multi-source variant: for each pinned target t, returns min over the given (source, initial_dist) pairs of initial_dist + dist(source, t).

Panics if sources is empty or contains node ids out of range.

Auto Trait Implementations§

§

impl<'a> !Sync for CCHOneToMany<'a>

§

impl<'a> Freeze for CCHOneToMany<'a>

§

impl<'a> RefUnwindSafe for CCHOneToMany<'a>

§

impl<'a> Send for CCHOneToMany<'a>

§

impl<'a> Unpin for CCHOneToMany<'a>

§

impl<'a> UnsafeUnpin for CCHOneToMany<'a>

§

impl<'a> UnwindSafe for CCHOneToMany<'a>

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> 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, 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.