ContextGraph distance intelligence answers the structural question that pure semantic similarity cannot: given two nodes, what is their precise relationship in terms of graph topology, path weight, and inferential confidence? Use it to annotate attribution chains with hop counts and confidence decay, rank retrieval results by structural proximity to an anchor node, and surface implied connections for analyst review.
Distance Intelligence feeds into proximity-blended retrieval (
proximity_weight on retrieve()), causal chain analysis (trace_decision_causality()), and advanced precedent search (find_precedents_hybrid()). Enable it by passing include_distance_metadata=True on neighbor queries or proximity_weight > 0 on retrieval calls.Distance Bands: Turning Hop Counts into Meaning
The first tool in distance intelligence isclassify_path_distance — it maps any BFS depth to a human-readable band that carries semantic meaning.
| Band | Hop Range | What it means in practice |
|---|---|---|
"direct" | 0–1 | Direct relationship — high confidence inferences |
"near" | 2–3 | Two-hop neighbourhood — closely related, reliable |
"mid-range" | 4–6 | Reachable but semantically separated |
"distant" | 7+ | Weakly coupled — treat inferences with caution |
include_distance_metadata=True, proximity_weight > 0, or trace_decision_causality(). You do not compute them manually — they are attached to the result.
Confidence Decay: How Trust Erodes Along a Path
Each hop along a path multiplies the accumulated confidence by the edge weight. The product —confidence_decay — is the single most useful signal for deciding whether a multi-hop inference is trustworthy.
nato_target node is reachable — but with only 0.669 confidence decay. That means any inference drawn from the connection between APT29 and the NATO contractor carries a 33% uncertainty budget accumulated across three hops. At “near” band, the inference is still usable; at “distant” band with similar decay, you would flag it for human review.
Getting All Neighbors with Distance Metadata
get_neighbor_distances returns every reachable node up to a given hop depth, filtered by a minimum confidence threshold, ordered by nearest hops first and strongest decay first within each hop.
Finding the Shortest Path Between Two Nodes
PathFinder exposes five path algorithms. The right one depends on whether you need the single cheapest path, multiple alternative paths, or all paths from a source.
Proximity-Blended Retrieval
Standard semantic retrieval ranks results by text similarity to the query. Proximity-blended retrieval adds a second signal: how structurally close is each result to an anchor node in the graph? Theproximity_weight parameter controls the blend.
proximity_weight > 0, each result gains proximity_score, combined_score, hop_distance, distance_band, confidence_decay, and path_to_anchor — giving you a complete picture of why each result ranked where it did.
Finding Structurally Similar Nodes
When you want to know which other nodes in the graph behave like a given node — same connectivity pattern or similar text —find_similar_nodes exposes the modes implemented on ContextGraph today.
similarity_type="content" compares node text/content, while similarity_type="structural" compares neighbourhood topology. Other values currently fall back to content similarity, so reserve "embedding" for lower-level KG APIs rather than ContextGraph.find_similar_nodes().
Domain Examples
- Defense — CTI/Threat
- Security — SOC/Incident
- Life Science — Clinical/Pharma
- Banking — Risk/Compliance
Finding the primary attribution path from a C2 IP to a threat actor, then finding all alternative corroboration paths to strengthen the attribution case before it goes into an intelligence product.
Related Guides
- Context Graphs —
ContextGraphnode and edge model;add_edge(weight=...)feeds confidence decay - Graph Analytics — centrality, community detection, Node2Vec embeddings, link prediction
- Agent Memory — proximity-blended retrieval (
proximity_weight) integrates distance intelligence into memory search - Decision Intelligence —
trace_decision_causality()for causal chains with distance annotations - Reasoning & Rules —
TemporalReasoningEnginefor Allen interval algebra over time-bounded graph nodes
