In GQL, graph pattern matching (GPM) is the process of searching for nodes, edges, paths and subgraphs within a graph that conform to a specified graph pattern. The graph pattern describes a particular structure of nodes and edges, and their labels and properties.
The GPM is performed through the MATCH
statement, its basic form is MATCH <graph pattern>
. The database engine then retrieves all parts of the graph that match the defined graph pattern.
A graph pattern is made up with various components. Follow the sequence below to learn how to write graph patterns in GQL:
While a graph patterns a list of path patterns, a path pattern is built with element patterns. Collectively, all of these can be referred to as graph patterns in general.
Apart from the MATCH
statement, the path patterns are also utilized in the INSERT
statement to insert new nodes and edges into the graph.