SearchTree

Struct SearchTree 

Source
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

Source

pub fn new(direction: Direction) -> Self

Create a new empty search tree with the specified orientation

Source

pub fn with_root(root_label: Label, orientation: Direction) -> Self

Create a new search tree with the given root node.

Source

pub fn set_root(&mut self, root_label: Label)

Set the root node of the tree

Source

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

Source

pub fn iter<'a>( &'a self, ) -> Box<dyn Iterator<Item = (&'a Label, &'a SearchTreeNode)> + 'a>

Source

pub fn keys<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Label> + 'a>

Source

pub fn values<'a>(&'a self) -> Box<dyn Iterator<Item = &'a SearchTreeNode> + 'a>

Source

pub fn get(&self, label: &Label) -> Option<&SearchTreeNode>

Get a node by its label

Source

pub fn get_min_cost_label(&self, vertex: VertexId) -> Option<&Label>

gets the label with the minimum cost associated with a vertex

Source

pub fn get_labels(&self, vertex: VertexId) -> Option<&HashSet<Label>>

Find labels for the given vertex ID

Source

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 label
  • compare - a comparison function
  • min - if true, find the minimal value according to the ordering function F, otherwise, the max
Source

pub fn get_mut(&mut self, label: &Label) -> Option<&mut SearchTreeNode>

Get a mutable reference to a node by its label

Source

pub fn root(&self) -> Option<&Label>

Get the root label

Source

pub fn get_parent(&self, label: &Label) -> Option<&SearchTreeNode>

Get the parent of a node

Source

pub fn get_children(&self, label: &Label) -> Vec<&SearchTreeNode>

Get all children of a node

Source

pub fn get_child_labels(&self, label: &Label) -> Vec<Label>

Get all child labels of a node

Source

pub fn contains(&self, label: &Label) -> bool

Check if the tree contains a node with the given label

Source

pub fn len(&self) -> usize

Get the number of nodes in the tree

Source

pub fn is_empty(&self) -> bool

Check if the tree is empty

Source

pub fn direction(&self) -> Direction

Get the tree orientation

Source

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.

Source

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 vertex dst of 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)

Source

pub fn backtrack( &self, leaf_vertex: VertexId, ) -> Result<Vec<EdgeTraversal>, SearchTreeError>

Backtrack from a leaf vertex to construct a path using the tree’s inherent direction

§Arguments
  • leaf_vertex - The vertex ID to backtrack from
§Returns

A path of EdgeTraversals from root to leaf (forward) or leaf to root (reverse)

Source

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.

Source

pub fn labels(&self) -> impl Iterator<Item = &Label>

Get all labels in the tree

Source

pub fn nodes(&self) -> impl Iterator<Item = &SearchTreeNode>

Get all nodes in the tree

Trait Implementations§

Source§

impl Allocative for SearchTree

Source§

fn visit<'allocative_a, 'allocative_b: 'allocative_a>( &self, visitor: &'allocative_a mut Visitor<'allocative_b>, )

Source§

impl Clone for SearchTree

Source§

fn clone(&self) -> SearchTree

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SearchTree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SearchTree

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool