Skip to main content

classify_graph_subgraph

Function classify_graph_subgraph 

Source
pub fn classify_graph_subgraph(query: &str) -> Vec<EdgeType>
Expand description

Classify a query into the MAGMA edge types to use for subgraph-scoped BFS retrieval.

Pure heuristic, zero latency — no LLM call. Returns a prioritised list of EdgeTypes.

Rules (checked in order):

  1. Causal markers → include Causal
  2. Temporal markers → include Temporal
  3. Entity/structural markers → include Entity
  4. Semantic is always included as fallback to guarantee recall >= current untyped BFS.

Multiple markers may match, producing a union of detected types.

§Example

let types = classify_graph_subgraph("why did X happen");
assert!(types.contains(&EdgeType::Causal));
assert!(types.contains(&EdgeType::Semantic));