pub struct CCHQuery<'a> { /* private fields */ }
Implementations§
Source§impl<'a> CCHQuery<'a>
impl<'a> CCHQuery<'a>
Sourcepub fn new(metric: &'a CCHMetric<'a>) -> Self
pub fn new(metric: &'a CCHMetric<'a>) -> Self
Allocate a new reusable shortest-path query bound to a given customized CCHMetric
.
The query object stores its own frontier / label buffers and can be reset and reused for many (s, t) pairs or multi-source / multi-target batches. You may have multiple query objects referencing the same metric concurrently (read-only access to metric data).
Thread-safety: Send
but not Sync
; do not mutate from multiple threads simultaneously.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset internal state (clears sources, targets, labels) so the object can be reused.
Call this before configuring a new multi-source / multi-target batch. Does not change the bound metric pointer – create a new query if you need a different metric.
Sourcepub fn add_source(&mut self, s: u32, dist: u32)
pub fn add_source(&mut self, s: u32, dist: u32)
Add a source node with an initial distance (normally 0). Multiple calls allow a multi- source query. Distances let you model already-traversed partial paths.
Sourcepub fn add_target(&mut self, t: u32, dist: u32)
pub fn add_target(&mut self, t: u32, dist: u32)
Add a target node with an initial distance (normally 0). Multiple calls allow multi-target queries; the algorithm stops when the frontiers settle the optimal distance to any target.
Sourcepub fn run(&mut self)
pub fn run(&mut self)
Execute the forward/backward upward/downward search to settle the shortest path between the added sources and targets. Must be called after at least one source and one target.
Sourcepub fn distance(&self) -> Option<u32>
pub fn distance(&self) -> Option<u32>
Return the shortest path distance after CCHQuery::run
.
Returns None
if no target is reachable (internally distance equals i32::MAX
).
Panics: if called before run()
.
Sourcepub fn node_path(&self) -> Vec<u32>
pub fn node_path(&self) -> Vec<u32>
Reconstruct and return the node id sequence of the current best path.
Returns empty vec if no target is reachable.
Panics: if called before run()
. Returns an empty vector only if source==target and the
implementation chooses to represent a trivial path that way (normally length>=1).
Sourcepub fn arc_path(&self) -> Vec<u32>
pub fn arc_path(&self) -> Vec<u32>
Reconstruct and return the original arc ids along the shortest path (after unpacking shortcuts). Useful if you need per-arc attributes (speed limits, geometry). Order matches the traversal direction from a chosen source to target.
Returns empty vec if no target is reachable.
Panics: if called before run()
.