Discover 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.
text
Alice --WORKS_AT--> Acme
Two entities connected through intermediate nodes (multi-hop path).
text
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.
text
Distance: 3 hops
Path: Alice → Acme → BetaCorp → California
Complete enumeration of all possible connection routes between nodes.
text
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.
text
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.
text
Alice works at Acme
Acme partners with BetaCorp
BetaCorp is located in California
Therefore: Alice is connected to California through her employer's partnership
text
BFS finds: Alice → Company → Partner → Location
Distance: 3 hops (shortest)
text
DFS explores: Alice → Person1 → Person2 → Company → Location
Distance: 4 hops
text
Weighted shortest path:
Alice --(0.9)--> Acme --(0.8)--> BetaCorp
Total weight: 0.72 (confidence product)
text
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)
text
Precomputed distances for rapid queries
Alice ↔ BetaCorp: 2 hops
Alice ↔ California: 3 hops
Identify the most direct connection.
text
Query: find_shortest_path("Alice", "California")
Result: Alice → Acme → BetaCorp → California
Distance: 3 hops
Discover all possible connections.
text
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.
text
Query: find_paths_by_types("Alice", "California", types=["works_at", "partner_of"])
Result: Only paths using specified relationships
Consider edge properties (confidence, weight, cost).
text
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.
text
Pattern detected: Person → Company → Partner → Location
Frequency: 3 paths match this pattern
Strength: 85% of paths follow this structure
Prioritize shorter paths (fewer hops).
text
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.
text
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.
text
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.
text
Path A: Directly business-relevant (score: 0.95)
Path B: Indirectly related (score: 0.60)
Rank: Path A first
Include/exclude specific relationship types.
text
Include: works_at, partner_of, located_in
Exclude: knows, follows
Result: Only business-relevant paths
Restrict maximum path length.
text
Max depth: 4 hops
Paths > 4 hops filtered out
Rationale: Distant connections less relevant
Include only edges above confidence threshold.
text
Min confidence: 0.75
Edges below 0.75 excluded from paths
Result: Only high-confidence paths
Consider time-based properties.
text
Time window: 2020-2023
Exclude relationships outside window
Result: Historically relevant paths only
Convert paths to natural language.
text
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.
text
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.
text
"Strong connection (confidence: 85%)"
"Weak connection (confidence: 40%)"
"Multiple independent paths (high redundancy)"
IssueCauseSolutionNo path foundEntities disconnectedCheck graph connectivityToo many pathsHighly connected graphApply depth limit, filter typesPath too longDistant entitiesIncrease max_depth or accept distanceLow confidenceWeak relationshipsApply confidence thresholdTimeoutComplex traversalLimit depth, use shortest path onlyMemory overflowLarge result setPaginate 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