GraphQueryMatcher<T>
Models & Types · AiDotNet.RetrievalAugmentedGeneration.Graph
Simple pattern matching for graph queries (inspired by Cypher/SPARQL but simplified).
For Beginners
Pattern matching is like SQL for graphs.
SQL Example:
SELECT * FROM persons WHERE name = 'Alice'
Graph Pattern Example:
(Person {name: "Alice"})-[KNOWS]->(Person)
Meaning: Find all people that Alice knows
Another Example:
(Person)-[WORKS_AT]->(Company {name: "Google"})
Meaning: Find all people who work at Google
This is much more natural for relationship-heavy data!
How It Works
Supports basic graph pattern matching queries like:
- (Person)-[KNOWS]->(Person)
- (Person {name: “Alice”})-[WORKS_AT]->(Company)
- (a:Person)-[r:KNOWS]->(b:Person)
Constructors
| Constructor | Summary |
|---|---|
GraphQueryMatcher(KnowledgeGraph<T> graph) |
Initializes a new instance of the GraphQueryMatcher class. |
Methods
| Method | Summary |
|---|---|
List<GraphNode<T>> FindNodes(string label, Dictionary<string, object> properties) |
Finds nodes matching a label and optional property filters. |
List<GraphPath<T>> ExecutePattern(string pattern) |
Executes a simple pattern query string. |
List<GraphPath<T>> FindPaths(string sourceLabel, string relationshipType, string targetLabel, Dictionary<string, object> sourceProperties, Dictionary<string, object> targetProperties) |
Finds paths matching a pattern: (source label)-[relationship type]->(target label). |
List<List<GraphNode<T>>> FindPathsOfLength(string sourceId, int pathLength, string relationshipType) |
Finds all paths of specified length from a source node. |
List<List<GraphNode<T>>> FindShortestPaths(string sourceId, string targetId, int maxDepth) |
Finds all shortest paths between two nodes. |