Home / Companies / Neo4j / Blog / Post Details
Content Deep Dive

Getting From Denmark Hill to Gatwick Airport With Quantified Path Patterns

Blog post from Neo4j

Post Details
Company
Date Published
Author
Finbar Good
Word Count
2,453
Language
English
Hacker News Points
-
Summary

Planning a journey on a railway network can be done using algorithms based on Scalable Transfer Patterns or A*; however, brute force approaches are unlikely to work due to their computational complexity. A new Cypher feature called quantified path patterns (QPPs) was introduced in Neo4j version 5.9 and offers several advantages over existing variable-length relationships, including a more concise syntax, the ability to match any number of nodes and relationships, and inline filters that can prune unwanted results as the graph is traversed. Using QPPs, it's possible to find the shortest distance between two stations by anchoring the beginning with the calling point at Denmark Hill and ending with the calling point at Gatwick Airport, filtering out paths that move too far in the wrong direction, and connecting the calling points to specific stop nodes. The query performance is significantly improved when adding filters to eliminate London terminal routes, making QPPs a useful tool for real-time journey planning.