Graph pattern matching sits at the very core of Cypher®.
It is the mechanism used to navigate, describe and extract data from a graph by applying a declarative pattern.
Inside a MATCH clause, you can use graph patterns to define the data you are searching for and the data to return.
Graph pattern matching can also be used without a
MATCH clause, in the subqueries EXISTS, COUNT, and COLLECT.
A graph pattern describes data using a syntax that is similar to how the nodes and relationships of a property graph are drawn on a whiteboard. On a whiteboard, nodes are drawn as circles and relationships are drawn as arrows. Cypher represents the circles as a pair of parentheses, and the arrows as dashes and greater-than or less-than symbols:
These simple patterns for nodes and relationships form the building blocks of path patterns that can match paths of a fixed length. As well as discussing simple patterns, this chapter will cover more complex patterns, showing how to match patterns of variable length, inline filters for improved query performance, and how to add cycles and non-linear shapes to path patterns.
This chapter includes three sections:
Was this page helpful?