pub struct GraphTraversal { /* private fields */ }Expand description
Graph traversal system implementing various search algorithms
Implementations§
Source§impl GraphTraversal
impl GraphTraversal
Sourcepub fn new(config: TraversalConfig) -> Self
pub fn new(config: TraversalConfig) -> Self
Create a new graph traversal system
Sourcepub fn bfs(
&self,
graph: &KnowledgeGraph,
source: &EntityId,
) -> Result<TraversalResult>
pub fn bfs( &self, graph: &KnowledgeGraph, source: &EntityId, ) -> Result<TraversalResult>
Breadth-First Search (BFS) from a source entity
BFS explores the graph level by level, guaranteeing shortest paths. Ideal for finding entities within a certain distance from the source.
§Arguments
graph- The knowledge graph to traversesource- Starting entity ID
§Returns
TraversalResult with entities, relationships, and distances
Sourcepub fn dfs(
&self,
graph: &KnowledgeGraph,
source: &EntityId,
) -> Result<TraversalResult>
pub fn dfs( &self, graph: &KnowledgeGraph, source: &EntityId, ) -> Result<TraversalResult>
Depth-First Search (DFS) from a source entity
DFS explores as far as possible along each branch before backtracking. Useful for finding all possible paths and deep exploration.
§Arguments
graph- The knowledge graph to traversesource- Starting entity ID
§Returns
TraversalResult with entities, relationships, and discovered paths
Sourcepub fn ego_network(
&self,
graph: &KnowledgeGraph,
entity_id: &EntityId,
k_hops: Option<usize>,
) -> Result<TraversalResult>
pub fn ego_network( &self, graph: &KnowledgeGraph, entity_id: &EntityId, k_hops: Option<usize>, ) -> Result<TraversalResult>
Extract K-hop ego-network around an entity
An ego-network is a subgraph containing all entities within K hops of the source entity. This is useful for context-aware retrieval.
§Arguments
graph- The knowledge graphentity_id- Center entity for the ego-networkk_hops- Number of hops to include (defaults to config.max_depth)
§Returns
TraversalResult with the ego-network subgraph
Sourcepub fn multi_source_bfs(
&self,
graph: &KnowledgeGraph,
sources: &[EntityId],
) -> Result<TraversalResult>
pub fn multi_source_bfs( &self, graph: &KnowledgeGraph, sources: &[EntityId], ) -> Result<TraversalResult>
Sourcepub fn find_all_paths(
&self,
graph: &KnowledgeGraph,
source: &EntityId,
target: &EntityId,
) -> Result<TraversalResult>
pub fn find_all_paths( &self, graph: &KnowledgeGraph, source: &EntityId, target: &EntityId, ) -> Result<TraversalResult>
Sourcepub fn query_focused_subgraph(
&self,
graph: &KnowledgeGraph,
seed_entities: &[EntityId],
expansion_hops: usize,
) -> Result<TraversalResult>
pub fn query_focused_subgraph( &self, graph: &KnowledgeGraph, seed_entities: &[EntityId], expansion_hops: usize, ) -> Result<TraversalResult>
Extract query-focused subgraph
Extracts a subgraph relevant to a specific query by:
- Identifying seed entities from query
- Expanding via ego-networks
- Filtering by relevance
§Arguments
graph- The knowledge graphseed_entities- Starting entities identified in queryexpansion_hops- How many hops to expand
§Returns
TraversalResult with query-relevant subgraph
Auto Trait Implementations§
impl Freeze for GraphTraversal
impl RefUnwindSafe for GraphTraversal
impl Send for GraphTraversal
impl Sync for GraphTraversal
impl Unpin for GraphTraversal
impl UnsafeUnpin for GraphTraversal
impl UnwindSafe for GraphTraversal
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> 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>
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