pub struct PathFinder { /* private fields */ }Expand description
Knowledge-graph path finder.
Implementations§
Source§impl PathFinder
impl PathFinder
Sourcepub fn new(edges: Vec<KnowledgeEdge>, config: PathFinderConfig) -> Self
pub fn new(edges: Vec<KnowledgeEdge>, config: PathFinderConfig) -> Self
Build a path finder from a set of edges.
Sourcepub fn add_edge(&mut self, edge: KnowledgeEdge)
pub fn add_edge(&mut self, edge: KnowledgeEdge)
Add a single edge to the graph.
Sourcepub fn bfs_paths(
&self,
source: &str,
target: &str,
max_depth: usize,
) -> Vec<KnowledgePath>
pub fn bfs_paths( &self, source: &str, target: &str, max_depth: usize, ) -> Vec<KnowledgePath>
Find all paths from source to target using BFS up to
max_depth hops.
Returns paths sorted by score (descending).
Sourcepub fn dfs_paths(
&self,
source: &str,
target: &str,
max_depth: usize,
) -> Vec<KnowledgePath>
pub fn dfs_paths( &self, source: &str, target: &str, max_depth: usize, ) -> Vec<KnowledgePath>
Find all paths from source to target using DFS up to
max_depth hops.
Sourcepub fn shortest_path(&self, source: &str, target: &str) -> Option<KnowledgePath>
pub fn shortest_path(&self, source: &str, target: &str) -> Option<KnowledgePath>
Find the shortest path (minimum hops) from source to target.
Returns None when no path exists within max_depth.
Sourcepub fn multi_hop_paths(
&self,
source: &str,
max_depth: usize,
) -> Vec<KnowledgePath>
pub fn multi_hop_paths( &self, source: &str, max_depth: usize, ) -> Vec<KnowledgePath>
Collect all paths up to depth N (multi-hop collection).
Returns paths to all reachable nodes that are different from source.
Useful for building context windows.
Sourcepub fn stats(&self, paths: &[KnowledgePath]) -> PathFinderStats
pub fn stats(&self, paths: &[KnowledgePath]) -> PathFinderStats
Compute search statistics for the paths returned by a previous search.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes in the graph.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Number of edges in the graph.
Auto Trait Implementations§
impl Freeze for PathFinder
impl RefUnwindSafe for PathFinder
impl Send for PathFinder
impl Sync for PathFinder
impl Unpin for PathFinder
impl UnsafeUnpin for PathFinder
impl UnwindSafe for PathFinder
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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