Skip to main content

bfs_with_predecessors

Function bfs_with_predecessors 

Source
pub fn bfs_with_predecessors(
    conn: &Connection,
    seed_entity_ids: &[i64],
    namespace: &str,
    min_weight: f64,
    max_hops: u32,
    max_neighbors_per_hop: Option<usize>,
) -> Result<(EntityDepthMap, PredecessorMap), AppError>
Expand description

BFS that also returns a predecessor map for path reconstruction.

Used by deep-research to reconstruct directed evidence chains from discovered entities back to their seeds.

Returns (entity_depth, predecessor) where:

  • entity_depth: depth of each reached entity (0 = seed).
  • predecessor: the BFS tree edge that first reached each non-seed entity.

ยงErrors

Propagates AppError::Database (exit 10) on SQLite query failures.