Pattern Matching Tutorial Summary

We have covered a lot of territory in this tutorial:

  • Pattern matching syntax:

    • Each hop can be a choice of multiple, individually directed edge types

    • The Kleene star (asterisk) and a min…​max range enable each hop to be repeated.

    • GSQL automatically finds the shortest paths that satisfy a variable length path.

    • A virtual match table has a column for each vertex or edge alias in a multi-hop path, and a row for each graph path that satisfies the pattern.

    • The ACCUM clause iterates on each row in the match table.

    • The POST-ACCUM clause iterates on one vertex alias; a query can have multiple POST-ACCUM clauses.

  • Best practices for writing pattern matching queries:

    • Put the smaller vertex set on the left end.

    • Specify all vertex and edge types explicitly.

    • Use the PER clause to reduce the match table size.

With a little practice, you will be writing GSQL pattern matching queries to efficiently solve real-world problems. You can post your feedback and questions on the GSQL community forum. Our community members and developers love to hear any feedback from your graph journey of using GSQL and are ready to help clarify any doubts.