pub struct PathRanker;Expand description
Stateless path-finding and scoring engine
Implementations§
Source§impl PathRanker
impl PathRanker
Sourcepub fn find_paths(
graph: &KnowledgeGraph,
start: &str,
end: &str,
max_hops: usize,
) -> Vec<KgPath>
pub fn find_paths( graph: &KnowledgeGraph, start: &str, end: &str, max_hops: usize, ) -> Vec<KgPath>
Find all simple paths from start to end with at most max_hops edges.
Uses iterative DFS with an explicit stack to avoid stack overflow on large graphs.
Sourcepub fn score_path(
graph: &KnowledgeGraph,
path: &KgPath,
config: &PathRankingConfig,
) -> f64
pub fn score_path( graph: &KnowledgeGraph, path: &KgPath, config: &PathRankingConfig, ) -> f64
Score a single path according to config.
score = (Σ edge_weights) * weight_factor * hop_penalty^hop_count * (Π edge_confidences) * confidence_factor + (Σ node_importance) * importance_bonus
Sourcepub fn rank_paths(
graph: &KnowledgeGraph,
paths: Vec<KgPath>,
config: &PathRankingConfig,
) -> Vec<(KgPath, f64)>
pub fn rank_paths( graph: &KnowledgeGraph, paths: Vec<KgPath>, config: &PathRankingConfig, ) -> Vec<(KgPath, f64)>
Sort paths by descending score and return (path, score) pairs.
Sourcepub fn shortest_path_dijkstra(
graph: &KnowledgeGraph,
start: &str,
end: &str,
) -> Option<KgPath>
pub fn shortest_path_dijkstra( graph: &KnowledgeGraph, start: &str, end: &str, ) -> Option<KgPath>
Find the shortest path from start to end using Dijkstra’s algorithm.
Distance metric: d = 1/weight (higher weight = shorter distance).
Edges with weight ≤ 0 are treated as distance f64::INFINITY.
Sourcepub fn most_relevant_paths(
graph: &KnowledgeGraph,
start: &str,
end: &str,
max_hops: usize,
top_k: usize,
config: &PathRankingConfig,
) -> Vec<(KgPath, f64)>
pub fn most_relevant_paths( graph: &KnowledgeGraph, start: &str, end: &str, max_hops: usize, top_k: usize, config: &PathRankingConfig, ) -> Vec<(KgPath, f64)>
Find all paths up to max_hops, rank them, and return the top-k.
Auto Trait Implementations§
impl Freeze for PathRanker
impl RefUnwindSafe for PathRanker
impl Send for PathRanker
impl Sync for PathRanker
impl Unpin for PathRanker
impl UnsafeUnpin for PathRanker
impl UnwindSafe for PathRanker
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