Folding
The pattern matching algorithm obeys several constraints. One constraint is the injectivity of matches with respect to nodes, i. e., no two query variables containing nodes may be bound to the same node of the graph. However, there are situations where this constraint it too restrictive. One solution is then to completely disable the requirement of injectivity, but a more fine-grained mechanism is given by folding clauses,
Folding clauses are suffixes of whole node patterns, separated by the symbol |, and
list the identifiers of those preceding node patterns which may be bound to the same node:
a:Node --> b:Node --> c:Node|a a:Node, b:Node, c:Node|a|b
The first pattern looks for a sequence of connected nodes which may be a cycle (c may coincide with a). The second pattern searches for three unrelated nodes where c may coincide with both a and b. Note that this also means that a may coincide with b in the case that c coincides with a and b.
