pub struct SearchTree { /* private fields */ }Expand description
A search tree that supports efficient lookups and bi-directional parent/child traversal Designed for route planning algorithms that need both indexing and backtracking capabilities
Implementations§
Source§impl SearchTree
impl SearchTree
Sourcepub fn new_stateful(direction: Direction) -> Self
pub fn new_stateful(direction: Direction) -> Self
Create a new empty search tree with the specified orientation that supports Labels that contain state.
Sourcepub fn new_vertex_oriented(direction: Direction) -> Self
pub fn new_vertex_oriented(direction: Direction) -> Self
Create a new empty search tree with the specified orientation that supports Labels that have no state (Label::Vertex).
Sourcepub fn with_root(
root_label: Label,
orientation: Direction,
) -> Result<Self, SearchTreeError>
pub fn with_root( root_label: Label, orientation: Direction, ) -> Result<Self, SearchTreeError>
Create a new search tree with the given root node.
Sourcepub fn set_root(&mut self, root_label: Label) -> Result<(), SearchTreeError>
pub fn set_root(&mut self, root_label: Label) -> Result<(), SearchTreeError>
Set the root node of the tree
Sourcepub fn insert_trajectory(
&mut self,
parent_label: Label,
edge_traversal: EdgeTraversal,
child_label: Label,
) -> Result<(), SearchTreeError>
pub fn insert_trajectory( &mut self, parent_label: Label, edge_traversal: EdgeTraversal, child_label: Label, ) -> Result<(), SearchTreeError>
Insert the trajectory (parent) -[edge]-> (child) as a node in the tree. it is assumed that the incoming edge traversal has already been deemed dominant over any matching trajectory already existing in the tree.
pub fn iter<'a>( &'a self, ) -> Box<dyn Iterator<Item = (Label, &'a SearchTreeNode)> + 'a>
pub fn keys<'a>(&'a self) -> Box<dyn Iterator<Item = Label> + 'a>
pub fn values<'a>(&'a self) -> Box<dyn Iterator<Item = &'a SearchTreeNode> + 'a>
Sourcepub fn get(&self, label: &Label) -> Option<&SearchTreeNode>
pub fn get(&self, label: &Label) -> Option<&SearchTreeNode>
Get a node by its label
Sourcepub fn get_min_accumulated_cost_label(
&self,
destination_vertex: VertexId,
) -> Result<(Label, Cost), SearchTreeError>
pub fn get_min_accumulated_cost_label( &self, destination_vertex: VertexId, ) -> Result<(Label, Cost), SearchTreeError>
gets the label with the minimum accumulated tree cost associated with the destination vertex of a search.
Sourcepub fn get_labels(
&self,
vertex: VertexId,
) -> Box<dyn Iterator<Item = Label> + '_>
pub fn get_labels( &self, vertex: VertexId, ) -> Box<dyn Iterator<Item = Label> + '_>
Find labels for the given vertex ID
Sourcepub fn calculate_total_objective_cost(
&self,
label: &Label,
) -> Result<Cost, SearchTreeError>
pub fn calculate_total_objective_cost( &self, label: &Label, ) -> Result<Cost, SearchTreeError>
Sourcepub fn get_mut(&mut self, label: &Label) -> Option<&mut SearchTreeNode>
pub fn get_mut(&mut self, label: &Label) -> Option<&mut SearchTreeNode>
Get a mutable reference to a node by its label
Sourcepub fn get_parent(&self, label: &Label) -> Option<&SearchTreeNode>
pub fn get_parent(&self, label: &Label) -> Option<&SearchTreeNode>
Get the parent of a node
Sourcepub fn contains(&self, label: &Label) -> bool
pub fn contains(&self, label: &Label) -> bool
Check if the tree contains a node with the given label
Sourcepub fn backtrack_with_depth(
&self,
leaf_vertex: VertexId,
depth: u64,
) -> Result<Vec<EdgeTraversal>, SearchTreeError>
pub fn backtrack_with_depth( &self, leaf_vertex: VertexId, depth: u64, ) -> Result<Vec<EdgeTraversal>, SearchTreeError>
Backtrack from a leaf vertex to construct a path using the tree’s inherent direction and limit the backtracking depth to some nonzero count of edges.
§Arguments
leaf_vertex- The vertex ID to backtrack from. this should be the destination vertexdstof the graph triplet (src)-[edge]->(dst).depth- max number of edges to find for the path starting at leaf_vertex
§Returns
A path of EdgeTraversals from root to leaf (forward) or leaf to root (reverse)
Sourcepub fn backtrack(
&self,
leaf_vertex: VertexId,
) -> Result<Vec<EdgeTraversal>, SearchTreeError>
pub fn backtrack( &self, leaf_vertex: VertexId, ) -> Result<Vec<EdgeTraversal>, SearchTreeError>
Sourcepub fn backtrack_label(
&self,
label: &Label,
) -> Result<Vec<EdgeTraversal>, SearchTreeError>
pub fn backtrack_label( &self, label: &Label, ) -> Result<Vec<EdgeTraversal>, SearchTreeError>
convenience method to backtrack from some label.
Sourcepub fn backtrack_label_with_depth(
&self,
label: &Label,
depth: u64,
) -> Result<Vec<EdgeTraversal>, SearchTreeError>
pub fn backtrack_label_with_depth( &self, label: &Label, depth: u64, ) -> Result<Vec<EdgeTraversal>, SearchTreeError>
convenience method to backtrack from some label to some depth.
Sourcepub fn backtrack_edge_oriented_route(
&self,
target: (EdgeListId, EdgeId),
graph: Arc<Graph>,
) -> Result<Vec<EdgeTraversal>, SearchTreeError>
pub fn backtrack_edge_oriented_route( &self, target: (EdgeListId, EdgeId), graph: Arc<Graph>, ) -> Result<Vec<EdgeTraversal>, SearchTreeError>
backtrack for edge-oriented search, begins from source vertex of target edge.
Sourcepub fn reconstruct_path(
&self,
target_label: &Label,
depth: Option<u64>,
) -> Result<Vec<EdgeTraversal>, SearchTreeError>
pub fn reconstruct_path( &self, target_label: &Label, depth: Option<u64>, ) -> Result<Vec<EdgeTraversal>, SearchTreeError>
Reconstruct a path from root to the given target label This is the primary backtracking method for route reconstruction If depth is provided, the path will be limited to a specified number of EdgeTraversals.
Sourcepub fn predecessor(
&self,
child: &Label,
) -> Result<Option<(&EdgeTraversal, &Label)>, SearchTreeError>
pub fn predecessor( &self, child: &Label, ) -> Result<Option<(&EdgeTraversal, &Label)>, SearchTreeError>
Sourcepub fn nodes(&self) -> impl Iterator<Item = &SearchTreeNode>
pub fn nodes(&self) -> impl Iterator<Item = &SearchTreeNode>
Get all nodes in the tree
Trait Implementations§
Source§impl Allocative for SearchTree
impl Allocative for SearchTree
Source§impl Clone for SearchTree
impl Clone for SearchTree
Source§fn clone(&self) -> SearchTree
fn clone(&self) -> SearchTree
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SearchTree
impl Debug for SearchTree
Auto Trait Implementations§
impl Freeze for SearchTree
impl RefUnwindSafe for SearchTree
impl Send for SearchTree
impl Sync for SearchTree
impl Unpin for SearchTree
impl UnsafeUnpin for SearchTree
impl UnwindSafe for SearchTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more