pub fn traverse_from_memories_with_hops(
conn: &Connection,
seed_memory_ids: &[i64],
namespace: &str,
min_weight: f64,
max_hops: u32,
) -> Result<Vec<(i64, u32)>, AppError>Expand description
BFS graph traversal returning the hop distance for each reached memory.
Returns (memory_id, hop_count) for every live memory reachable through
entity and relationship edges, excluding the seed memories themselves.
hop_count is the minimum BFS depth at which the memory’s entity was
discovered, starting at 1 for direct neighbours of the seed entities.
The walk follows source_id -> target_id only and skips edges whose
weight is below min_weight or whose namespace differs.
§Errors
Propagates AppError::Database (exit 10) on SQLite query failures.
§Examples
use rusqlite::Connection;
use sqlite_graphrag::graph::traverse_from_memories_with_hops;
// Empty seed list returns immediately without querying the database.
let conn = Connection::open_in_memory().unwrap();
let hops = traverse_from_memories_with_hops(&conn, &[], "global", 0.5, 3).unwrap();
assert!(hops.is_empty());use rusqlite::Connection;
use sqlite_graphrag::graph::traverse_from_memories_with_hops;
// max_hops == 0 returns immediately without traversal.
let conn = Connection::open_in_memory().unwrap();
let hops = traverse_from_memories_with_hops(&conn, &[1, 2], "global", 0.5, 0).unwrap();
assert!(hops.is_empty());