How to Find the Shortest Path
Find the shortest path between two nodes in your graph.
Quick Answer
grph path graph.gexf source-node target-node
Examples
Basic Path Finding
# Find route between two stations
grph path london-underground.gexf kings-cross bank
# Output:
# Path from kings-cross to bank
# Length: 4 edges
# Path: kings-cross → russell-square → holborn → chancery-lane → bank
Check If Path Exists First
# Check if connected
grph has-path graph.gexf nodeA nodeB
# Output: Path exists: Yes/No
Find Path in Directed Graph
For directed graphs, direction matters:
# Can we get FROM A TO B?
grph path flights.gexf LTN DBV
# This might fail even if the reverse path exists
grph path flights.gexf DBV LTN
Related
- Find All Possible Routes - When you need alternatives
grph path --help- Full command documentation