pub fn traverse_from_memories(
conn: &Connection,
seed_memory_ids: &[i64],
namespace: &str,
min_weight: f64,
max_hops: u32,
) -> Result<Vec<i64>, AppError>Expand description
Traverses the entity graph by BFS from seed memories.
Returns memory_ids reachable through entity and relationship edges,
excluding the seeds themselves. The algorithm:
- Collects entities associated with seeds via
memory_entities. - Runs BFS over
relationshipsfiltered byweight >= min_weightandnamespace. - Returns memories linked to discovered entities (excluding soft-deleted).
§Errors
Propaga AppError::Database (exit 10) em falhas de consulta SQLite.
§Examples
use rusqlite::Connection;
use sqlite_graphrag::graph::traverse_from_memories;
// Lista de sementes vazia retorna imediatamente sem consultar o banco.
let conn = Connection::open_in_memory().unwrap();
let ids = traverse_from_memories(&conn, &[], "global", 0.5, 3).unwrap();
assert!(ids.is_empty());use rusqlite::Connection;
use sqlite_graphrag::graph::traverse_from_memories;
// max_hops == 0 retorna imediatamente sem traversal.
let conn = Connection::open_in_memory().unwrap();
let ids = traverse_from_memories(&conn, &[1, 2], "global", 0.5, 0).unwrap();
assert!(ids.is_empty());