Install
openclaw skills install graph-path-reasoning-analyzerAnalyze and discover paths between entities in knowledge graphs to explain relationships, identify indirect connections, and provide reasoning over traversal patterns. Supports shortest path, all paths, filtering, ranking, and explanation generation.
openclaw skills install graph-path-reasoning-analyzerDiscover and analyze paths between entities to explain relationships and understand indirect connections in knowledge graphs.
This skill enables comprehensive path reasoning by traversing graphs to find connections between entities, explaining how they are related through intermediate nodes and relationships, and ranking paths by various metrics.
Two entities connected by a single relationship edge.
Alice --WORKS_AT--> Acme
Two entities connected through intermediate nodes (multi-hop path).
Alice --WORKS_AT--> Acme --PARTNER_OF--> BetaCorp --LOCATED_IN--> California
(Alice is indirectly connected to California)
The minimum number of hops between two nodes, often the most direct explanation.
Distance: 3 hops
Path: Alice → Acme → BetaCorp → California
Complete enumeration of all possible connection routes between nodes.
Path 1: Alice → Acme → BetaCorp (distance 2)
Path 2: Alice → Acme → Partner1 → BetaCorp (distance 3)
Path 3: Alice → Employee_of_Partner → BetaCorp (distance 2)
Multiple independent paths connecting entities, indicating robustness or redundancy.
Paths found: 5
Diversity: High (multiple independent routes)
Critical edges: 1 (single point of failure edges)
A sequence of relationships explaining entity connections, optimized for explainability.
Alice works at Acme
Acme partners with BetaCorp
BetaCorp is located in California
Therefore: Alice is connected to California through her employer's partnership
BFS finds: Alice → Company → Partner → Location
Distance: 3 hops (shortest)
DFS explores: Alice → Person1 → Person2 → Company → Location
Distance: 4 hops
Weighted shortest path:
Alice --(0.9)--> Acme --(0.8)--> BetaCorp
Total weight: 0.72 (confidence product)
Top-3 paths by relevance:
1. Direct path (distance: 2, confidence: 0.95)
2. Alt path A (distance: 3, confidence: 0.85)
3. Alt path B (distance: 3, confidence: 0.80)
Precomputed distances for rapid queries
Alice ↔ BetaCorp: 2 hops
Alice ↔ California: 3 hops
Identify the most direct connection.
Query: find_shortest_path("Alice", "California")
Result: Alice → Acme → BetaCorp → California
Distance: 3 hops
Discover all possible connections.
Query: find_all_paths("Alice", "California", max_length=5)
Result: 4 paths found
Path 1: Alice → Acme → BetaCorp → California (3 hops)
Path 2: Alice → Acme → Partner1 → Supplier → California (4 hops)
Path 3: Alice → Employee_friend → Company → California (3 hops)
Path 4: Alice → ... → California (4 hops)
Find paths with specific relationship types.
Query: find_paths_by_types("Alice", "California", types=["works_at", "partner_of"])
Result: Only paths using specified relationships
Consider edge properties (confidence, weight, cost).
Query: find_best_path("Alice", "California", metric="confidence")
Result: Path with highest cumulative confidence
Confidence: 0.95 * 0.90 * 0.85 = 0.726
Identify repeating patterns in paths.
Pattern detected: Person → Company → Partner → Location
Frequency: 3 paths match this pattern
Strength: 85% of paths follow this structure
Prioritize shorter paths (fewer hops).
Path A: 2 hops (score: 1.0)
Path B: 3 hops (score: 0.67)
Path C: 4 hops (score: 0.5)
Score by cumulative relationship confidence.
Path A: conf=0.95*0.90 = 0.855 (score: 1.0)
Path B: conf=0.85*0.80*0.75 = 0.510 (score: 0.60)
Prioritize diverse paths using different edges.
Path A: Uses edges {e1, e2, e3}
Path B: Uses edges {e4, e5, e6} (different edges)
Diversity score for B: Higher (uses new edges)
Rank by domain-specific relevance scores.
Path A: Directly business-relevant (score: 0.95)
Path B: Indirectly related (score: 0.60)
Rank: Path A first
Include/exclude specific relationship types.
Include: works_at, partner_of, located_in
Exclude: knows, follows
Result: Only business-relevant paths
Restrict maximum path length.
Max depth: 4 hops
Paths > 4 hops filtered out
Rationale: Distant connections less relevant
Include only edges above confidence threshold.
Min confidence: 0.75
Edges below 0.75 excluded from paths
Result: Only high-confidence paths
Consider time-based properties.
Time window: 2020-2023
Exclude relationships outside window
Result: Historically relevant paths only
Convert paths to natural language.
Path: Alice → Acme → BetaCorp
Template: "{source} works at {intermediate}.
{intermediate} partners with {target}."
Result: "Alice works at Acme. Acme partners with BetaCorp."
Express paths in various formats.
Neo4j: MATCH path = (a:Person)-[*3]-(b:Company) RETURN path
SPARQL: ?alice ?p1 ?company . ?company ?p2 ?target .
RDF: alice --works_at--> acme --partner_of--> betacorp
Emphasize path quality/strength.
"Strong connection (confidence: 85%)"
"Weak connection (confidence: 40%)"
"Multiple independent paths (high redundancy)"
| Issue | Cause | Solution |
|---|---|---|
| No path found | Entities disconnected | Check graph connectivity |
| Too many paths | Highly connected graph | Apply depth limit, filter types |
| Path too long | Distant entities | Increase max_depth or accept distance |
| Low confidence | Weak relationships | Apply confidence threshold |
| Timeout | Complex traversal | Limit depth, use shortest path only |
| Memory overflow | Large result set | Paginate results, use K-shortest |
✓ Limit traversal depth - Prevent exponential growth in large graphs
✓ Filter relationship types - Focus on relevant connections
✓ Prioritize shortest paths - Most direct explanations are clearest
✓ Add confidence scores - Weight relationships by certainty
✓ Generate explanations - Convert paths to human-readable form
✓ Cache frequent paths - Improve performance for repeated queries
✓ Detect path patterns - Understand common connection structures
✓ Rank by relevance - Present most important paths first
✓ Handle disconnected nodes - Return meaningful error messages
✓ Monitor performance - Track path finding latency
Find paths from source to multiple targets simultaneously.
Group similar paths by structure or properties.
Identify unusual or suspicious path patterns.
Track how paths change over time in dynamic graphs.
Find paths spanning multiple interconnected graphs.
This skill integrates with:
networkx - Path finding algorithmsigraph - Fast path computationgraph-tool - High-performance graph analysisastar - A* search implementationheapq - Priority queue for Dijkstra'scollections.deque - BFS queuedataclasses - Configuration and resultstyping - Type hintsmatplotlib - Plot pathspyvis - Interactive network visualizationplotly - Graph visualizationVersion: 1.0.0