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(direction: Direction) -> Self
pub fn new(direction: Direction) -> Self
Create a new empty search tree with the specified orientation
Sourcepub fn with_root(root_label: Label, orientation: Direction) -> Self
pub fn with_root(root_label: Label, orientation: Direction) -> Self
Create a new search tree with the given root node.
Sourcepub fn insert(
&mut self,
parent_label: Label,
edge_traversal: EdgeTraversal,
child_label: Label,
) -> Result<(), SearchTreeError>
pub fn insert( &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
pub fn iter<'a>( &'a self, ) -> Box<dyn Iterator<Item = (&'a Label, &'a SearchTreeNode)> + 'a>
pub fn keys<'a>(&'a self) -> Box<dyn Iterator<Item = &'a 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_cost_label(&self, vertex: VertexId) -> Option<&Label>
pub fn get_min_cost_label(&self, vertex: VertexId) -> Option<&Label>
gets the label with the minimum cost associated with a vertex
Sourcepub fn get_labels(&self, vertex: VertexId) -> Option<&HashSet<Label>>
pub fn get_labels(&self, vertex: VertexId) -> Option<&HashSet<Label>>
Find labels for the given vertex ID
Sourcepub fn get_label_by<F>(
&self,
vertex: VertexId,
compare: F,
min: bool,
) -> Option<&Label>
pub fn get_label_by<F>( &self, vertex: VertexId, compare: F, min: bool, ) -> Option<&Label>
finds a single label by picking the one that is maximal/minimal wrt some comparison function. for most cases, using the method get_min_cost_label is the correct choice.
§Arguments
vertex- the vertex expected to match some labelcompare- a comparison functionmin- if true, find the minimal value according to the ordering function F, otherwise, the max
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 get_children(&self, label: &Label) -> Vec<&SearchTreeNode>
pub fn get_children(&self, label: &Label) -> Vec<&SearchTreeNode>
Get all children of a node
Sourcepub fn get_child_labels(&self, label: &Label) -> Vec<Label>
pub fn get_child_labels(&self, label: &Label) -> Vec<Label>
Get all child labels 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 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 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_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 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 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