5.1 About Graph Pattern
The GRAPH_TABLE
operator in a SQL graph query contains a
graph pattern.
A graph pattern is expressed between the input graph name and the
COLUMNS
clause inside the GRAPH_TABLE
operator.
A graph pattern contains one or more comma-separated path patterns, which are composed of vertex and edge patterns. For example, the following path pattern has two vertex patterns and one edge pattern:
(v1) -[e]-> (v2)
A vertex pattern is enclosed in parentheses and specifies how to match a single vertex. An edge pattern is enclosed by a square bracket with delimiters on the left and right side of the edge pattern and specifies how to match a single edge.
Also, the available arrow tokens for edge patterns are summarized in the following table:
Table 5-1 Arrow Tokens for Edge Patterns
Directionality | Bracketed Syntax | Abbreviated SyntaxFoot 1 |
---|---|---|
Directed to the right | -[ ]-> |
-> |
Directed to the left | <-[ ]- |
-> |
Any directed edge (right or left) | <-[ ]-> or -[
]- |
- |
Footnote 1
- There are no brackets for the arrows in the “abbreviated syntax” column.
- All edge labels will be considered as no edge label is specified. Hence, filtering on a specific edge is not supported.
- An element variable.
- A label expression which is that part in an element pattern that
starts with the keyword
IS
and is followed by a list of one or more label names. If there is more than one label name, then these are separated by vertical bars. - An element pattern
WHERE
clause which expresses a search condition on the element variable declared by the element pattern.
The following sections explain the graph pattern concepts more in detail:
- Graph Element Variables
Vertex and edge pattern variables ranges over vertices and edges respectively. - Label Expressions
A label expression in a vertex or an edge element pattern is introduced by the keywordIS
. - Accessing Label Properties
You can access a property inside a graph element pattern, in the out-of-lineWHERE
clause or in theCOLUMNS
clause.
Parent topic: SQL Graph Queries