-
Notifications
You must be signed in to change notification settings - Fork 1
features_recursive_path
GitHub Actions edited this page Jan 2, 2026
·
1 revision
Rekursive Pfad-Abfragen mit Variable Length für Multi-Hop Reasoning.
- 📋 Übersicht
- ✨ Features
- 🚀 Schnellstart
- 📖 Detaillierte Dokumentation
- 💡 Best Practices
- 🔧 Troubleshooting
- 📚 Siehe auch
- 📝 Changelog
Status: MVP Complete (31. Oktober 2025)
Feature Set: Rekursive Pfadabfragen, Multi-Hop Traversal, Temporale Graph-Queries
Das Themis Query-Engine-Modul unterstützt jetzt rekursive Pfadabfragen für Graph-Traversals mit variabler Tiefe und optionaler zeitlicher Filterung.
- Recursive Path Queries: Variable Tiefe ohne festes Limit (1..max_depth)
- Multi-Hop Traversal: Automatische Pfadfindung über mehrere Knoten
-
Temporal Graph Support: Zeitabhängige Kanten mit
valid_from/valid_to - Shortest Path: Dijkstra-Algorithmus für kürzeste Pfade
- Breadth-First Search: Alle erreichbaren Knoten bis zu einer bestimmten Tiefe
struct RecursivePathQuery {
std::string start_node; // Start-Knoten (erforderlich)
std::string end_node; // Ziel-Knoten (optional, leer = BFS)
std::string edge_type; // Kanten-Typ-Filter (reserviert)
size_t max_depth = 5; // Maximale Traversal-Tiefe
std::optional<std::string> valid_from; // Zeitfenster Start (ms)
std::optional<std::string> valid_to; // Zeitfenster Ende (ms)
};std::pair<Status, std::vector<std::vector<std::string>>>
executeRecursivePathQuery(const RecursivePathQuery& q) const;Rückgabe:
-
Status: OK oder Fehlermeldung -
vector<vector<string>>: Liste von Pfaden (jeder Pfad ist eine Sequenz von Knoten-IDs)
#include "query/query_engine.h"
#include "index/graph_index.h"
// Setup
RocksDBWrapper db;
db.open("data/mydb");
SecondaryIndexManager secIdx(db);
GraphIndexManager graphIdx(db);
QueryEngine engine(db, secIdx, graphIdx);
// Query: Finde kürzesten Pfad von A nach D
RecursivePathQuery q;
q.start_node = "A";
q.end_node = "D";
q.max_depth = 10;
auto [st, paths] = engine.executeRecursivePathQuery(q);
if (st.ok && !paths.empty()) {
// paths[0] = ["A", "B", "C", "D"]
for (const auto& node : paths[0]) {
std::cout << node << " -> ";
}
}// Query: Finde alle Knoten erreichbar von A (max Tiefe 3)
RecursivePathQuery q;
q.start_node = "A";
// Kein end_node = BFS-Modus
q.max_depth = 3;
auto [st, paths] = engine.executeRecursivePathQuery(q);
if (st.ok) {
std::cout << "Erreichbare Knoten: " << paths.size() << std::endl;
for (const auto& path : paths) {
std::cout << " " << path.back() << std::endl; // Ziel-Knoten
}
}// Query: Finde Pfad, der zur Zeit 1600ms gültig war
RecursivePathQuery q;
q.start_node = "A";
q.end_node = "C";
q.max_depth = 5;
q.valid_from = "1600"; // Zeitstempel in Millisekunden
auto [st, paths] = engine.executeRecursivePathQuery(q);
// Nur Kanten, die bei valid_from <= 1600 <= valid_to sind, werden traversiert// Query: Finde Pfad im Zeitfenster [1000, 2000]
RecursivePathQuery q;
q.start_node = "A";
q.end_node = "D";
q.max_depth = 10;
q.valid_from = "1000";
q.valid_to = "2000";
auto [st, paths] = engine.executeRecursivePathQuery(q);
// Verwendet Mittelpunkt des Zeitfensters (1500ms) als Query-ZeitstempelBaseEntity node("nodes", "node_id");
node.set("name", "Node Name");
node.set("type", "Person");
// ... weitere Attribute
db.putEntity(node);BaseEntity edge("edges", "edge_id");
edge.set("_from", "node_a"); // Erforderlich
edge.set("_to", "node_b"); // Erforderlich
edge.set("_weight", 1.5); // Optional für gewichtete Pfade
db.putEntity(edge);
graphIdx.addEdge(edge);BaseEntity edge("edges", "edge_id");
edge.set("_from", "node_a");
edge.set("_to", "node_b");
edge.set("valid_from", 1000); // Millisekunden seit Epoch
edge.set("valid_to", 2000); // Millisekunden seit Epoch
db.putEntity(edge);
graphIdx.addEdge(edge);Zeitfenster-Semantik:
-
valid_from= null → gültig seit Anbeginn der Zeit -
valid_to= null → gültig bis in alle Ewigkeit - Query-Zeitstempel
tmuss in[valid_from, valid_to]liegen
Verwendet Dijkstra-Algorithmus:
- Zeit-Komplexität: O((V + E) log V)
- Gewichtete Graphen unterstützt (Feld
_weight) - Temporal variant:
dijkstraAtTime()filtert Kanten nach Zeitstempel
Verwendet Breadth-First Search:
- Zeit-Komplexität: O(V + E)
- Findet alle Knoten bis zu
max_depth - Temporal variant:
bfsAtTime()filtert Kanten nach Zeitstempel
TemporalFilter filter = TemporalFilter::at(timestamp_ms);
// Für jede Kante:
bool isValid = filter.isValid(edge.valid_from, edge.valid_to);| Operation | Time Complexity | Space Complexity | Notes |
|---|---|---|---|
| Shortest Path (Dijkstra) | O((V + E) log V) | O(V) | Mit Priority Queue |
| BFS Traversal | O(V + E) | O(V) | Breadth-First |
| Temporal Filter Check | O(1) | O(1) | Per Edge |
| Path Reconstruction | O(depth) | O(depth) | Linear in Tiefe |
Skalierung:
- In-Memory Graph Topology: O(1) Nachbarschaftsabfragen
- RocksDB Fallback: O(log N) bei kalten Kanten
- Empfohlenes Limit: max_depth <= 10 für interaktive Queries
- ✅
SimplePathQuery: Kürzester Pfad A → D in linearem Graph - ✅
PathNotFound: Kein Pfad in Gegenrichtung (gerichteter Graph) - ✅
BFSReachableNodes: BFS findet alle erreichbaren Knoten - ✅
TemporalPathQuery_ValidTime: Pfad zur Zeit 1600ms - ✅
TemporalPathQuery_InvalidTime: Kein Pfad zur Zeit 500ms - ✅
MaxDepthLimit: Respektiert max_depth Grenze - ✅
EmptyStartNode: Fehlerbehandlung für leeren Start - ✅
NoGraphIndexManager: Fehlerbehandlung ohne Graph-Index
Test-Ausführung:
cd build
.\Release\themis_tests.exe --gtest_filter="RecursivePathQueryTest.*"- ✅ Single shortest path (Dijkstra)
- ✅ BFS für erreichbare Knoten
- ✅ Temporale Filterung (valid_from/valid_to)
- ✅ Max-Tiefe-Limit
- All Paths Enumeration: Nicht nur kürzester, sondern alle Pfade
- Path Constraints: Filter auf Kanten-Attributen (z.B.
edge_type) - Variable-Length Patterns: Cypher-Style
[:KNOWS*1..5] - Recursive CTEs: SQL-ähnliche WITH RECURSIVE Syntax
- Weighted Temporal Paths: Kombination von Zeitfenster und Gewichtung
- Bidirectional Search: Schnellere Pfadsuche für große Graphen
- Graph Projection: Virtuelle Subgraphen für spezielle Queries
// Kürzester Pfad
FOR v, e, p IN 1..5 OUTBOUND 'nodes/A' GRAPH 'my_graph'
FILTER p.vertices[*]._key == 'D'
LIMIT 1
RETURN p
// Temporale Pfadabfrage
FOR v, e, p IN 1..3 OUTBOUND 'nodes/A' GRAPH 'my_graph'
FILTER e.valid_from <= @timestamp AND e.valid_to >= @timestamp
FILTER p.vertices[-1]._key == 'D'
RETURN p
// Alle erreichbaren Knoten
FOR v IN 1..3 OUTBOUND 'nodes/A' GRAPH 'my_graph'
RETURN DISTINCT v
-
docs/architecture.md- System-Architektur-Übersicht -
include/index/graph_index.h- Graph-Index API -
include/index/temporal_graph.h- Temporal-Filter Design -
tests/test_graph_index.cpp- Graph-Index Unit-Tests -
tests/test_temporal_graph.cpp- Temporal-Graph Tests
Letzte Aktualisierung: 31. Oktober 2025
Version: 1.0.0 (MVP)
Status: ✅ Production Ready
- Architecture-ACCESS-MODEL-IMPLEMENTATION-SUMMARY
- Architecture-ADR-003-pg-dump-sql-parser
- Architecture-BASEENTITY-PRINCIPLE
- Architecture-CACHE-STORAGE-INTEGRATION
- Architecture-CMAKE-ARCHITECTURE
- Architecture-CMAKE-FLAGS-REFERENCE
- Architecture-CMAKE-MODULAR-ARCHITECTURE
- Architecture-CONCERNS-ARCHITECTURE-DIAGRAM
- Architecture-CONCERNS-IMPLEMENTATION-SUMMARY
- Architecture-CONTENT-MODEL
- Architecture-COPILOT-THEMISDB-GRAPH-RAG-BACKEND-ARCHITECTURE
- Architecture-CRYPTO-AND-KEYS
- Architecture-FEATURE-FLAGS-REFERENCE
- Architecture-GPU-ARCHITECTURE-REVIEW-TEMPLATE
- Architecture-HTTP-SHUTDOWN-HARDENING
- Architecture-MIGRATION-GUIDE-CONCERNS
- Architecture-MIGRATION-GUIDE-v13-v14
- Architecture-MODULARIZATION-GUIDE
- Architecture-MODULAR-ARCHITECTURE-ROADMAP
- Architecture-MODULE-ARCHITECTURE-INDEX
- Architecture-P1D01-ISSMPLUGIN-DESIGN-REVIEW
- Architecture-P1-D01-ISSMPLUGIN-DESIGN-REVIEW
- Architecture-P1-D08-MAMBA-GOVERNANCE-CONTRACT
- Architecture-P1-P2-IMPLEMENTATION-COMPLETION-INDEX
- Architecture-PHASE0-COMPLETION-ASSESSMENT
- Architecture-PHASE3-QUERYENGINE-DI-ARCHITECTURE
- Architecture-PHASE4-INDEX-MANAGER-DI
- Architecture-POSTGRESQL-WIRE-PROTOCOL
- Architecture-QUERYENGINE-IMPLEMENTATION-GUIDE
- Architecture-QUERY-SCHEDULING
- Architecture-RAFT-CONSENSUS-DESIGN
- Architecture-README
- Architecture-README-SSM-HYBRID-IMPLEMENTATION
- Architecture-REFACTORING-SUMMARY
- Architecture-RESOURCE-POOLING
- Architecture-SOURCE-DIRECTORY-GUIDE
- Architecture-THEMIS-CORE-GUIDE
- Architecture-UNIFIED-ACCESS-MODEL
- Architecture-WAL-GRPC-MTLS-CONFIGURATION
- Architecture-WIRE-PROTOCOL-RETRY
- Architecture-boltzmann-observability-draft
- Architecture-experimental-logarithmic-vector-storage
- Architecture-llm-wiki-mvp-adr
- Architecture-rewrite-engine-architecture
- Architecture-rope-api-architecture
- Architecture-ssm-gguf-mamba-status
- Architecture-ssm-hybrid-analysis
- Architecture-ssm-hybrid-rollout-plan
- Architecture-ssm-plugin-interface-design-review
- Architecture-transaction-coordinators
- Architecture-wiki-secondary-index
- Architecture-wire-protocol
- Governance-DISABLED-STUB-POLICY
- Governance-DOCS-PR-POLICY
- Governance-GA-PROMOTION-SIGN-OFF
- Governance-GITHUB-MILESTONES-SETUP
- Governance-MATURITY-CLAIM-VERIFICATION-CHECKLIST
- Governance-MATURITY-EVIDENCE-REGISTRY
- Governance-MERGE-GATE-BOT-CONFIG
- Governance-MERGE-GATE-STATUS-LIVE
- Governance-PHASE3-ENFORCEMENT-RUNBOOK
- Governance-PHASE-1-CLOSURE-REPORT
- Governance-PHASE-CLOSURE-POLICY
- Governance-PHASE-DEPENDENCY-GRAPH
- Governance-PLUGIN-SUBMODULE-ROLLBACK
- Governance-PRODUCTION-READY-2026-DELIVERY-PLAN
- Governance-PR-VERSION-TARGETING
- Governance-PR-VERSION-TARGETING-BACKFILL
- Governance-QUERY-MODULE-STATUS
- Governance-README
- Governance-RELEASE-PROMOTION-GATE-POLICY
- Governance-RELEASE-VALIDATION-CHECKLIST
- Governance-SECURITY-MODULE-5671-EVIDENCE-SUMMARY
- Governance-SHARDING-P6-RESIDUAL-RISK-ACCEPTANCE
- Governance-SOURCECODE-COMPLIANCE-GOVERNANCE
- Governance-UPDATES-DEVELOPMENT-STATUS-SIGN-OFF
- Governance-WAVE-C-IMPLEMENTATION-COMPLETE
- Module-acceleration-Roadmap
- Module-access-model-Roadmap
- Module-ai-Roadmap
- Module-analytics-Roadmap
- Module-api-Roadmap
- Module-aql-Roadmap
- Module-auth-Roadmap
- Module-base-Roadmap
- Module-cache-Roadmap
- Module-cdc-Roadmap
- Module-chaos-Roadmap
- Module-chimera-Roadmap
- Module-config-Roadmap
- Module-content-Roadmap
- Module-core-Roadmap
- Module-distributed-knowledge-Roadmap
- Module-distributed-tensor-Roadmap
- Module-document-Roadmap
- Module-ethics-ai-Roadmap
- Module-evaluation-Roadmap
- Module-execution-Roadmap
- Module-exporters-Roadmap
- Module-failover-Roadmap
- Module-geo-Roadmap
- Module-governance-Roadmap
- Module-gpu-Roadmap
- Module-graph-Roadmap
- Module-image-analysis-Roadmap
- Module-importers-Roadmap
- Module-index-Roadmap
- Module-ingestion-Roadmap
- Module-llama-cpp-Roadmap
- Module-llm-Roadmap
- Module-llm-streaming-Roadmap
- Module-llm-wiki-Roadmap
- Module-maintenance-Roadmap
- Module-metadata-Roadmap
- Module-network-Roadmap
- Module-observability-Roadmap
- Module-onnx-clip-Roadmap
- Module-performance-Roadmap
- Module-plugins-Roadmap
- Module-process-Roadmap
- Module-projects-Roadmap
- Module-prompt-engineering-Roadmap
- Module-query-Roadmap
- Module-rag-Roadmap
- Module-replication-Roadmap
- Module-retrieval-Roadmap
- Module-rpc-grpc-Roadmap
- Module-scheduler-Roadmap
- Module-scraper-Roadmap
- Module-search-Roadmap
- Module-security-Roadmap
- Module-server-Roadmap
- Module-sharding-Roadmap
- Module-stable-diffusion-Roadmap
- Module-storage-Roadmap
- Module-temporal-Roadmap
- Module-tensor-Roadmap
- Module-themis-Roadmap
- Module-timeseries-Roadmap
- Module-toolbox-Roadmap
- Module-training-Roadmap
- Module-transaction-Roadmap
- Module-updates-Roadmap
- Module-user-storage-encrypted-Roadmap
- Module-utils-Roadmap
- Module-vector-search-Roadmap
- Module-voice-Roadmap
- Module-whisper-Roadmap