Finding paths in Cypher along with their shortest route
The most common operation in any graph database is graph traversal, which includes finding all possible paths between the two nodes, the shortest path, and the shortest weighted path. In this recipe, we will cover them with the help of examples.
Getting ready
Let's create some sample data of airports and routes between them, using the following Cypher queries:
CREATE (ATL:Airport { city:'Atlanta' }),(ORD:Airport { city:'Chicago' }),(LAX:Airport { city:'Los Angeles' }),(DFW:Airport { city:'Dallas/Fort Worth' }),(AUS:Airport { city:'Austin' }) CREATE (ATL)-[:ROUTE { time:22 }]->(AUS),(AUS)-[:ROUTE { time:35 }]->(LAX),(ATL)-[:ROUTE { time:40 }]->(DFW),(DFW)-[:ROUTE { time:34 }]->(LAX),(ORD)-[:ROUTE { time:13 }]->(ATL),(LAX)-[:ROUTE { time:63 }]->(ORD)
The following screenshot shows the Neo4j console depicting the sample airport and route data that was inserted into the Neo4j graph database:

How to do it...
We have divided...