SlideShare a Scribd company logo
Graph Gurus
Episode 14
Pattern Matching using GSQL Interpreted Mode
© 2019 TigerGraph. All Rights Reserved
Welcome
● Attendees are muted
● If you have any Zoom issues please contact the panelists via chat
● We will have 10 min for Q&A at the end so please send your questions
at any time using the Q&A tab in the Zoom menu
● The webinar will be recorded and sent via email
2
© 2019 TigerGraph. All Rights Reserved
Today's Gurus
3
Victor Lee
Director, Product Management
● BS in Electrical Engineering and Computer
Science from UC Berkeley
● MS in Electrical Engineering from Stanford
University
● PhD in Computer Science from Kent State
University focused on graph data mining
● 15+ years in tech industry
Mingxi Wu
VP, Engineering
● BS in Computer Science from Fudan University,
China
● MS in Computer Science from University of Florida
● PhD in Computer Science from University of
Florida
● 19+ years in data management industry &
research
© 2019 TigerGraph. All Rights Reserved
Agenda
4
● Pattern Matching Uses in Data Analytics
● GSQL Pattern Matching Syntax and Semantics
● Pattern Matching Using LDBC SNB Data (Demo)
● A Recommendation Application (Demo)
● Q&A
© 2019 TigerGraph. All Rights Reserved
Graph Use Cases
5
By Dan McCreary https://medium.com/@dmccreary/a-taxonomy-of-graph-use-cases-2ba34618cf78
© 2019 TigerGraph. All Rights Reserved
Graph Use Cases
6
Rule
Enforcement
Flexible
Modeling, Data
Integration
Insight from
Relationships
Reporting,
Auditing
Clustering,
Community,
Similarity,
Ranking
Finding
Connections,
Deep Link
Analysis
Anti-Fraud
Recommendation
Master Data
Management
Machine Learning,
Explainable AI
Entity
Resolution
Ad Hoc
Exploration,
Visual
Explainable
Results
Knowledge
Inference
Risk
Management
Data
Provenance
© 2019 TigerGraph. All Rights Reserved
Graph Use Cases
7
Rule
Enforcement
Flexible
Modeling, Data
Integration
Insight from
Relationships
Reporting,
Auditing
Clustering,
Community,
Similarity,
Ranking
Finding
Connections,
Deep Link
Analysis
Anti-Fraud
Recommendation
Master Data
Management
Machine Learning,
Explainable AI
Entity
Resolution
Ad Hoc
Exploration,
Visual
Explainable
Results
Knowledge
Inference
Risk
Management
Data
Provenance
Pattern
Matching/Search
© 2019 TigerGraph. All Rights Reserved
Graph Patterns
Any arrangement of connected nodes, used as a search input:
"Find all the occurrences like this"
Pattern Types
● Transactional Patterns
● Social Patterns
● Event Patterns
● Hybrid Patterns
Uses
● Recommendation
● Fraud/Crime
● Security/Risk/Rules
● Trends/Insight
© 2019 TigerGraph. All Rights Reserved 9
Detecting Phone-Based Fraud by Analyzing Network or Graph
Relationship Features at China Mobile
Download the solution brief at - https://info.tigergraph.com/MachineLearning
© 2019 TigerGraph. All Rights Reserved
Pattern Matching Overview
10
● What is a pattern?
○ Pattern is a traversal trace on the graph schema
○ Use regular expression to represent the repetitive steps
○ Pattern can be linear, or nonlinear (tree, circle etc.)
● Example
○ Imagine a schema consisting of a Person vertex type and a
Friendship edge type.
○ A pattern
■ Person-(Friendship)-Person-(Friendship)-Person
■ Person-(Friendship*2)-Person
© 2019 TigerGraph. All Rights Reserved
Pattern Matching Overview
11
● What is Pattern Matching?
○ Pattern matching is the process of finding subgraphs in a
data graph that conforms to a given query pattern.
○ Input
■ Query Pattern P
■ Data Graph G
○ Output
■ Collection of matched instances M = {subgraphs of G}
© 2019 TigerGraph. All Rights Reserved
Query Pattern P
Data Graph G
© 2019 TigerGraph. All Rights Reserved
Query Pattern P
Data Graph G
First Match
© 2019 TigerGraph. All Rights Reserved
Query Pattern P
Data Graph G
First Match
Second Match
© 2019 TigerGraph. All Rights Reserved
Query Pattern P
Data Graph G
First Match
Second Match
Third Match
© 2019 TigerGraph. All Rights Reserved
GSQL Pattern Matching Overview
16
● Simple 1-Hop Pattern
● Repeating a 1-Hop Pattern
● Multi-Hop Linear Pattern
© 2019 TigerGraph. All Rights Reserved
Simple 1-Hop Pattern
17
Classic GSQL Syntax:
FROM X:x -((E1 | E2 | E3):e1)-> Y:y
● Semantics: Traverse from Left to Right
GSQL Pattern Matching Syntax:
FROM X:x -((E1> | <E2 | E3):e1)- Y:y
● Semantics: Pattern is a whole;
each edge's direction is a detail about the pattern
© 2019 TigerGraph. All Rights Reserved
Simple 1-Hop Pattern - Variations
18
1. FROM X:x -(E1:e1)- Y:y
○ E1 is an undirected edge. x, y bind to the end points of E1. e1 is alias to E1.
2. FROM X:x -(E2>:e2)- Y:y
○ Right directed edge, x binds to the source of E2, y binds to the target of E2. e2 is alias of E2.
3. FROM X:x -(<E3:e3)- Y:y
○ Left directed edge, y binds to the source of E3, x binds to the target of E3. e3 is alias of E3.
4. FROM X:x -(_:e)- Y:y
○ Any undirected edge pattern. "_" means any undirected edge type. e is alias of "_".
5. FROM X:x -(_>:e)- Y:y
○ Any right directed edge. "_>" means any right directed edge type. e is alias of "_>".
© 2019 TigerGraph. All Rights Reserved
Simple 1-Hop Pattern - Variations
19
6. FROM X:x -(<_:e)- Y:y
○ Any left directed edge. "<_" means any left directed edge type. e is alias of "<_".
7. FROM X:x -((<_|_):e)- Y:y
○ Any left directed or any undirected. "|" means OR. e is alias of (<_|_).
8. FROM X:x -((E1|E2>|<E3):e) - Y:y
○ Disjunctive 1-hop edge. (x,y) are connected by E1 or E2 or E3. e is alias of (E1|E2>|<E3).
9. FROM X:x -()- Y:y
○ any edge (directed or undirected) match this 1-hop pattern
○ Same as this: (<_|_>|_)
© 2019 TigerGraph. All Rights Reserved
Simple 1-Hop Pattern (cont.)
20
© 2019 TigerGraph. All Rights Reserved 21
© 2019 TigerGraph. All Rights Reserved
Repeating a 1-Hop Pattern - Unbounded Variations
22
1. FROM X:x - (E1*) - Y:y
○ X connect to Y via 0 or more repetition of undirected E1. * is called the Kleene star.
2. FROM X:x - (E2>*) - Y:y
○ X connect to Y via 0 or more repetition of rightward E2
3. FROM X:x - (<E3*) - Y:y
○ X connect to Y via 0 or more repetition of leftward E3
4. FROM X:x - (_*) - Y:y
○ X connect to Y via 0 or more undirected edges of any type
© 2019 TigerGraph. All Rights Reserved
Repeating a 1-Hop Pattern - Unbounded Variations
23
5. FROM X:x - (_>*) - Y:y
○ X connect to Y via 0 or more right-directed edges of any type
6. FROM X:x - (<_*) - Y:y
○ X connect to Y via 0 or more left-directed edges of any type
7. FROM X:x - ((E1|E2>|<E3)*) - Y:y
○ Either E1, E2> or <E3 can be chosen at each repetition.
© 2019 TigerGraph. All Rights Reserved
Repeating a 1-Hop Pattern - Bounded Variations
24
1. FROM X:x - (E1*2..) - Y:y
○ Lower bounds only. There is a chain of at least 2 E1 edges.
2. FROM X:x - (E2>*..3) - Y:y
○ Upper bounds only. There is a chain of between 0 and 3 E2 edges.
3. FROM X:x - (<E3*3..5) - Y:y
○ Both Lower and Upper bounds. There is a chain of 3 to 5 E3 edges.
4. FROM X:x - ((E1|E2>|<E3)*3) - Y:y
○ Exact bound. There is a chain of exactly 3 edges, where each edge is either E1, E2>, or <E3.
© 2019 TigerGraph. All Rights Reserved
Repeating a Pattern - Remarks
25
1. Edge aliases cannot be used together with a Kleene star.
○ When an edge is repeated, it would not clear which instance of the edge
the alias refers to.
2. Shortest path semantics.
○ When an edge is repeated with the Kleene star, we consider shortest path
matches only.
○ Counting and existence check of matched shortest path pattern is
tractable.
© 2019 TigerGraph. All Rights Reserved 26
Example: Shortest Matching Path
In above figure, for the pattern, 1 - (E>*) - 4, the following paths can reach 4 from 1.
1. 1->2->3->4
2. 1->2->3->5->6->2->3->4 (1 loop)
3. Any path 1>2, looping through 2->3->5->6->2 two or more times, and exiting
2>3>4
Only the first one is the shortest, and considered a match for the pattern.
© 2019 TigerGraph. All Rights Reserved 27
Specifying How Many Repetitions (cont.)
© 2019 TigerGraph. All Rights Reserved 28
Specifying How Many Repetitions (cont.)
© 2019 TigerGraph. All Rights Reserved
Multiple-Hop Linear Pattern
29
● 2-hop pattern
○ FROM X:x - (E1:e1) - Y:y - (E2>:e2)-Z:z
1st hop 2nd hop
Similarly, a 3-hop pattern concatenates three 1-hop patterns in sequence,
every two connecting patterns share one endpoint. Below Y:y and Z:z are
the connecting endpoints.
● 3-hop pattern
○ FROM X:x - (E2>:e2) - Y:y - (<E3:e3)- Z:z - (E4:e4) - U:u
1st hop 2nd hop 3rd hop
© 2019 TigerGraph. All Rights Reserved
Multiple-Hop Linear Pattern
30
● SELECT Clause
○ select pattern’s endpoints only
○ FROM X:x-(E2>:e2)-Y:y-(<E3:e3)-Z:z-(E4:e4)-U:u;
● FROM Clause
○ FROM pattern can be shortened
■ FROM X:x-(E2>:e2)-Y:y-(<E3:e3)-Z:z-(E4:e4)-U:u ⇒
■ FROM X:x-(E2>.<E3.E4)-U:u; //note: no alias is allowed for E.E style
● WHERE Clause
○ Conjunction of local hop predicate only
○ Last hop local predicate can refer to the starting end point
○ Kleene star breaks local hop predicate
● ACCUM and POST-ACCUM Clause
○ ACCUM clause executed for each matched instance
○ ACCUM to endpoints only
© 2019 TigerGraph. All Rights Reserved
How To Use In Upcoming Release 2.4
31
● Session Parameter
○ set syntax_version="v2" //for pattern match
○ set syntax_version="v1" //default, classic syntax
● Invoke Interpret GSQL Engine
○ INTERPRET QUERY QueryName (p1, p2, ..) //run existing query
○ INTERPRET QUERY () FOR GRAPH graphName { } //adhoc query
● Query Level Syntax Setting
○ CREATE QUERY (p1, p2.,.) Name FOR GRAPH test SYNTAX("v2") { }
○ INTERPRET QUERY () FOR GRAPH test SYNTAX("v1") { }
© 2019 TigerGraph. All Rights Reserved
Demo Setup
32
© 2019 TigerGraph. All Rights Reserved
Demo Setup
33
E1 1,003,605
E2 2,052,169
E3 1,003,605
E4 229,166
E5 1,611,869
E6 90,492
E7 2,698,393
E8 713,258
E9 309,766
E10 16,080
E11 1,575
E12 6,380
E13 2,052,169
E14 1,003,605
E15 9,892
E16 1,343
E17 111
E18 70
Total :
3.18M vertices
17.25M edges
11 vertex types
25 edge types
Vertex Stats
Edge Stats
Total comment post
compan
y university city country continent forum person tag tagclass
# attributes 6 8 3 3 3 3 3 3 10 3 3
# vertices 3.18 M 2,052,169 1,003,605 1,575 6,380 1,343 111 6 90,492 9,892 16,080 71
E19 180,623
E20 1,438,418
E21 751,677
E22 1,040,749
E23 1,011,420
E24 7,949
E25 21,654
© 2019 TigerGraph. All Rights Reserved
Demo Setup
34
© 2019 TigerGraph. All Rights Reserved
Demo On Docker
35
© 2019 TigerGraph. All Rights Reserved
Summary
36
Version 2.4
Available End Jun
● Pattern Matching enables
● Demo: Pattern Match Using LDBC Social Network Benchmark Data
○ Interpreted Mode on laptop Docker -- run queries instantly as
soon as you write them
● Demo: Pattern Matching in a Recommender Application
○ Interpreted Mode again
Q&A
Please send your questions via the Q&A menu in Zoom
37
© 2019 TigerGraph. All Rights Reserved
Developer Edition Available
We now offer Docker versions and VirtualBox versions of the TigerGraph
Developer Edition, so you can now run on
● MacOS
● Windows 10
● Linux
Developer Edition Download https://www.tigergraph.com/developer/
38
© 2019 TigerGraph. All Rights Reserved
NEW! Graph Gurus Developer Office Hours
39
Catch up on previous episodes of Graph Gurus:
https://www.tigergraph.com/webinars-and-events/
Every Thursday at 11:00 am Pacific
Talk directly with our engineers every
week. During office hours, you get
answers to any questions pertaining to
graph modeling and GSQL
programming.
https://info.tigergraph.com/officehours
© 2019 TigerGraph. All Rights Reserved
Additional Resources
40
New Developer Portal
https://www.tigergraph.com/developers/
Download the Developer Edition or Enterprise Free Trial
https://www.tigergraph.com/download/
Guru Scripts
https://github.com/tigergraph/ecosys/tree/master/guru_scripts
Join our Developer Forum
https://groups.google.com/a/opengsql.org/forum/#!forum/gsql-users
@TigerGraphDB youtube.com/tigergraph facebook.com/TigerGraphDB linkedin.com/company/TigerGraph

More Related Content

What's hot (20)

PDF
Stl meetup cloudera platform - january 2020
Adam Doyle
 
PDF
Scaling into Billions of Nodes and Relationships with Neo4j Graph Data Science
Neo4j
 
PDF
Intro to Delta Lake
Databricks
 
PDF
Democratizing Data Quality Through a Centralized Platform
Databricks
 
PDF
GraphFrames: Graph Queries In Spark SQL
Spark Summit
 
PDF
How to Build a Scylla Database Cluster that Fits Your Needs
ScyllaDB
 
PPTX
YugaByte DB Internals - Storage Engine and Transactions
Yugabyte
 
PDF
Architect’s Open-Source Guide for a Data Mesh Architecture
Databricks
 
PDF
Oracle Cloud Infrastructure:2022年8月度サービス・アップデート
オラクルエンジニア通信
 
PDF
[Oracle DBA & Developer Day 2016] しばちょう先生の特別講義!!ストレージ管理のベストプラクティス ~ASMからExada...
オラクルエンジニア通信
 
PPTX
SAP Extractorのソースエンドポイントとしての利用
QlikPresalesJapan
 
PDF
Databricks Delta Lake and Its Benefits
Databricks
 
PDF
Lessons from Building Large-Scale, Multi-Cloud, SaaS Software at Databricks
Databricks
 
PPTX
Where is my bottleneck? Performance troubleshooting in Flink
Flink Forward
 
PPTX
Azure Cloud Adoption Framework + Governance - Sana Khan and Jay Kumar
Timothy McAliley
 
PDF
Technical Deck Delta Live Tables.pdf
Ilham31574
 
PDF
【旧版】Oracle Exadata Cloud Service:サービス概要のご紹介 [2021年7月版]
オラクルエンジニア通信
 
PDF
Introduction to MLflow
Databricks
 
PDF
Batch Processing at Scale with Flink & Iceberg
Flink Forward
 
PDF
Apache Kafka With Spark Structured Streaming With Emma Liu, Nitin Saksena, Ra...
HostedbyConfluent
 
Stl meetup cloudera platform - january 2020
Adam Doyle
 
Scaling into Billions of Nodes and Relationships with Neo4j Graph Data Science
Neo4j
 
Intro to Delta Lake
Databricks
 
Democratizing Data Quality Through a Centralized Platform
Databricks
 
GraphFrames: Graph Queries In Spark SQL
Spark Summit
 
How to Build a Scylla Database Cluster that Fits Your Needs
ScyllaDB
 
YugaByte DB Internals - Storage Engine and Transactions
Yugabyte
 
Architect’s Open-Source Guide for a Data Mesh Architecture
Databricks
 
Oracle Cloud Infrastructure:2022年8月度サービス・アップデート
オラクルエンジニア通信
 
[Oracle DBA & Developer Day 2016] しばちょう先生の特別講義!!ストレージ管理のベストプラクティス ~ASMからExada...
オラクルエンジニア通信
 
SAP Extractorのソースエンドポイントとしての利用
QlikPresalesJapan
 
Databricks Delta Lake and Its Benefits
Databricks
 
Lessons from Building Large-Scale, Multi-Cloud, SaaS Software at Databricks
Databricks
 
Where is my bottleneck? Performance troubleshooting in Flink
Flink Forward
 
Azure Cloud Adoption Framework + Governance - Sana Khan and Jay Kumar
Timothy McAliley
 
Technical Deck Delta Live Tables.pdf
Ilham31574
 
【旧版】Oracle Exadata Cloud Service:サービス概要のご紹介 [2021年7月版]
オラクルエンジニア通信
 
Introduction to MLflow
Databricks
 
Batch Processing at Scale with Flink & Iceberg
Flink Forward
 
Apache Kafka With Spark Structured Streaming With Emma Liu, Nitin Saksena, Ra...
HostedbyConfluent
 

Similar to Graph Gurus Episode 14: Pattern Matching (20)

PDF
Graph Gurus 15: Introducing TigerGraph 2.4
TigerGraph
 
PPT
mathematics of network science: basic definitions
phdutm2009
 
PDF
EMF-IncQuery: Incremental evaluation of model queries over EMF models
Istvan Rath
 
PPT
5.5 graph mining
Krish_ver2
 
PDF
Bill howe 8_graphs
Mahammad Valiyev
 
PPTX
ppt 1.pptx
ShasidharaniD
 
PPTX
TREE ADT, TREE TRAVERSALS, BINARY TREE ADT
mohanrajm63
 
PPT
Lect12 graph mining
Houw Liong The
 
PDF
Graphhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.pdf
timoemin50
 
PDF
DFS-model Graph Modeling (CES 417) Lecture 6
DanialKhawaja4
 
PDF
Graph abstraction
openCypher
 
PPTX
Unit ix graph
Tribhuvan University
 
PDF
Graphs
Dwight Sabio
 
PDF
Graph Gurus Episode 26: Using Graph Algorithms for Advanced Analytics Part 1
TigerGraph
 
PPT
Trends In Graph Data Management And Mining
Srinath Srinivasa
 
PPTX
UNIT III.pptx
SwarndeviKm
 
PPT
14. GRAPH in data structures and algorithm.ppt
saurabhthege
 
PPTX
Data Structures and Agorithm: DS 21 Graph Theory.pptx
RashidFaridChishti
 
PDF
Incremental Graph Queries for Cypher
openCypher
 
PDF
DHHTGraphs - Modeling beyond plain graphs
dbildh
 
Graph Gurus 15: Introducing TigerGraph 2.4
TigerGraph
 
mathematics of network science: basic definitions
phdutm2009
 
EMF-IncQuery: Incremental evaluation of model queries over EMF models
Istvan Rath
 
5.5 graph mining
Krish_ver2
 
Bill howe 8_graphs
Mahammad Valiyev
 
ppt 1.pptx
ShasidharaniD
 
TREE ADT, TREE TRAVERSALS, BINARY TREE ADT
mohanrajm63
 
Lect12 graph mining
Houw Liong The
 
Graphhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.pdf
timoemin50
 
DFS-model Graph Modeling (CES 417) Lecture 6
DanialKhawaja4
 
Graph abstraction
openCypher
 
Unit ix graph
Tribhuvan University
 
Graphs
Dwight Sabio
 
Graph Gurus Episode 26: Using Graph Algorithms for Advanced Analytics Part 1
TigerGraph
 
Trends In Graph Data Management And Mining
Srinath Srinivasa
 
UNIT III.pptx
SwarndeviKm
 
14. GRAPH in data structures and algorithm.ppt
saurabhthege
 
Data Structures and Agorithm: DS 21 Graph Theory.pptx
RashidFaridChishti
 
Incremental Graph Queries for Cypher
openCypher
 
DHHTGraphs - Modeling beyond plain graphs
dbildh
 
Ad

More from TigerGraph (20)

PDF
MAXIMIZING THE VALUE OF SCIENTIFIC INFORMATION TO ACCELERATE INNOVATION
TigerGraph
 
PDF
Better Together: How Graph database enables easy data integration with Spark ...
TigerGraph
 
PDF
Building an accurate understanding of consumers based on real-world signals
TigerGraph
 
PDF
Care Intervention Assistant - Omaha Clinical Data Information System
TigerGraph
 
PDF
Correspondent Banking Networks
TigerGraph
 
PDF
Delivering Large Scale Real-time Graph Analytics with Dell Infrastructure and...
TigerGraph
 
PDF
Deploying an End-to-End TigerGraph Enterprise Architecture using Kafka, Maria...
TigerGraph
 
PDF
Fraud Detection and Compliance with Graph Learning
TigerGraph
 
PDF
Fraudulent credit card cash-out detection On Graphs
TigerGraph
 
PDF
FROM DATAFRAMES TO GRAPH Data Science with pyTigerGraph
TigerGraph
 
PDF
Customer Experience Management
TigerGraph
 
PDF
Graph+AI for Fin. Services
TigerGraph
 
PDF
Davraz - A graph visualization and exploration software.
TigerGraph
 
PDF
Plume - A Code Property Graph Extraction and Analysis Library
TigerGraph
 
PDF
TigerGraph.js
TigerGraph
 
PDF
GRAPHS FOR THE FUTURE ENERGY SYSTEMS
TigerGraph
 
PDF
Hardware Accelerated Machine Learning Solution for Detecting Fraud and Money ...
TigerGraph
 
PDF
How to Build An AI Based Customer Data Platform: Learn the design patterns fo...
TigerGraph
 
PDF
Machine Learning Feature Design with TigerGraph 3.0 No-Code GUI
TigerGraph
 
PDF
Recommendation Engine with In-Database Machine Learning
TigerGraph
 
MAXIMIZING THE VALUE OF SCIENTIFIC INFORMATION TO ACCELERATE INNOVATION
TigerGraph
 
Better Together: How Graph database enables easy data integration with Spark ...
TigerGraph
 
Building an accurate understanding of consumers based on real-world signals
TigerGraph
 
Care Intervention Assistant - Omaha Clinical Data Information System
TigerGraph
 
Correspondent Banking Networks
TigerGraph
 
Delivering Large Scale Real-time Graph Analytics with Dell Infrastructure and...
TigerGraph
 
Deploying an End-to-End TigerGraph Enterprise Architecture using Kafka, Maria...
TigerGraph
 
Fraud Detection and Compliance with Graph Learning
TigerGraph
 
Fraudulent credit card cash-out detection On Graphs
TigerGraph
 
FROM DATAFRAMES TO GRAPH Data Science with pyTigerGraph
TigerGraph
 
Customer Experience Management
TigerGraph
 
Graph+AI for Fin. Services
TigerGraph
 
Davraz - A graph visualization and exploration software.
TigerGraph
 
Plume - A Code Property Graph Extraction and Analysis Library
TigerGraph
 
TigerGraph.js
TigerGraph
 
GRAPHS FOR THE FUTURE ENERGY SYSTEMS
TigerGraph
 
Hardware Accelerated Machine Learning Solution for Detecting Fraud and Money ...
TigerGraph
 
How to Build An AI Based Customer Data Platform: Learn the design patterns fo...
TigerGraph
 
Machine Learning Feature Design with TigerGraph 3.0 No-Code GUI
TigerGraph
 
Recommendation Engine with In-Database Machine Learning
TigerGraph
 
Ad

Recently uploaded (20)

PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 

Graph Gurus Episode 14: Pattern Matching

  • 1. Graph Gurus Episode 14 Pattern Matching using GSQL Interpreted Mode
  • 2. © 2019 TigerGraph. All Rights Reserved Welcome ● Attendees are muted ● If you have any Zoom issues please contact the panelists via chat ● We will have 10 min for Q&A at the end so please send your questions at any time using the Q&A tab in the Zoom menu ● The webinar will be recorded and sent via email 2
  • 3. © 2019 TigerGraph. All Rights Reserved Today's Gurus 3 Victor Lee Director, Product Management ● BS in Electrical Engineering and Computer Science from UC Berkeley ● MS in Electrical Engineering from Stanford University ● PhD in Computer Science from Kent State University focused on graph data mining ● 15+ years in tech industry Mingxi Wu VP, Engineering ● BS in Computer Science from Fudan University, China ● MS in Computer Science from University of Florida ● PhD in Computer Science from University of Florida ● 19+ years in data management industry & research
  • 4. © 2019 TigerGraph. All Rights Reserved Agenda 4 ● Pattern Matching Uses in Data Analytics ● GSQL Pattern Matching Syntax and Semantics ● Pattern Matching Using LDBC SNB Data (Demo) ● A Recommendation Application (Demo) ● Q&A
  • 5. © 2019 TigerGraph. All Rights Reserved Graph Use Cases 5 By Dan McCreary https://medium.com/@dmccreary/a-taxonomy-of-graph-use-cases-2ba34618cf78
  • 6. © 2019 TigerGraph. All Rights Reserved Graph Use Cases 6 Rule Enforcement Flexible Modeling, Data Integration Insight from Relationships Reporting, Auditing Clustering, Community, Similarity, Ranking Finding Connections, Deep Link Analysis Anti-Fraud Recommendation Master Data Management Machine Learning, Explainable AI Entity Resolution Ad Hoc Exploration, Visual Explainable Results Knowledge Inference Risk Management Data Provenance
  • 7. © 2019 TigerGraph. All Rights Reserved Graph Use Cases 7 Rule Enforcement Flexible Modeling, Data Integration Insight from Relationships Reporting, Auditing Clustering, Community, Similarity, Ranking Finding Connections, Deep Link Analysis Anti-Fraud Recommendation Master Data Management Machine Learning, Explainable AI Entity Resolution Ad Hoc Exploration, Visual Explainable Results Knowledge Inference Risk Management Data Provenance Pattern Matching/Search
  • 8. © 2019 TigerGraph. All Rights Reserved Graph Patterns Any arrangement of connected nodes, used as a search input: "Find all the occurrences like this" Pattern Types ● Transactional Patterns ● Social Patterns ● Event Patterns ● Hybrid Patterns Uses ● Recommendation ● Fraud/Crime ● Security/Risk/Rules ● Trends/Insight
  • 9. © 2019 TigerGraph. All Rights Reserved 9 Detecting Phone-Based Fraud by Analyzing Network or Graph Relationship Features at China Mobile Download the solution brief at - https://info.tigergraph.com/MachineLearning
  • 10. © 2019 TigerGraph. All Rights Reserved Pattern Matching Overview 10 ● What is a pattern? ○ Pattern is a traversal trace on the graph schema ○ Use regular expression to represent the repetitive steps ○ Pattern can be linear, or nonlinear (tree, circle etc.) ● Example ○ Imagine a schema consisting of a Person vertex type and a Friendship edge type. ○ A pattern ■ Person-(Friendship)-Person-(Friendship)-Person ■ Person-(Friendship*2)-Person
  • 11. © 2019 TigerGraph. All Rights Reserved Pattern Matching Overview 11 ● What is Pattern Matching? ○ Pattern matching is the process of finding subgraphs in a data graph that conforms to a given query pattern. ○ Input ■ Query Pattern P ■ Data Graph G ○ Output ■ Collection of matched instances M = {subgraphs of G}
  • 12. © 2019 TigerGraph. All Rights Reserved Query Pattern P Data Graph G
  • 13. © 2019 TigerGraph. All Rights Reserved Query Pattern P Data Graph G First Match
  • 14. © 2019 TigerGraph. All Rights Reserved Query Pattern P Data Graph G First Match Second Match
  • 15. © 2019 TigerGraph. All Rights Reserved Query Pattern P Data Graph G First Match Second Match Third Match
  • 16. © 2019 TigerGraph. All Rights Reserved GSQL Pattern Matching Overview 16 ● Simple 1-Hop Pattern ● Repeating a 1-Hop Pattern ● Multi-Hop Linear Pattern
  • 17. © 2019 TigerGraph. All Rights Reserved Simple 1-Hop Pattern 17 Classic GSQL Syntax: FROM X:x -((E1 | E2 | E3):e1)-> Y:y ● Semantics: Traverse from Left to Right GSQL Pattern Matching Syntax: FROM X:x -((E1> | <E2 | E3):e1)- Y:y ● Semantics: Pattern is a whole; each edge's direction is a detail about the pattern
  • 18. © 2019 TigerGraph. All Rights Reserved Simple 1-Hop Pattern - Variations 18 1. FROM X:x -(E1:e1)- Y:y ○ E1 is an undirected edge. x, y bind to the end points of E1. e1 is alias to E1. 2. FROM X:x -(E2>:e2)- Y:y ○ Right directed edge, x binds to the source of E2, y binds to the target of E2. e2 is alias of E2. 3. FROM X:x -(<E3:e3)- Y:y ○ Left directed edge, y binds to the source of E3, x binds to the target of E3. e3 is alias of E3. 4. FROM X:x -(_:e)- Y:y ○ Any undirected edge pattern. "_" means any undirected edge type. e is alias of "_". 5. FROM X:x -(_>:e)- Y:y ○ Any right directed edge. "_>" means any right directed edge type. e is alias of "_>".
  • 19. © 2019 TigerGraph. All Rights Reserved Simple 1-Hop Pattern - Variations 19 6. FROM X:x -(<_:e)- Y:y ○ Any left directed edge. "<_" means any left directed edge type. e is alias of "<_". 7. FROM X:x -((<_|_):e)- Y:y ○ Any left directed or any undirected. "|" means OR. e is alias of (<_|_). 8. FROM X:x -((E1|E2>|<E3):e) - Y:y ○ Disjunctive 1-hop edge. (x,y) are connected by E1 or E2 or E3. e is alias of (E1|E2>|<E3). 9. FROM X:x -()- Y:y ○ any edge (directed or undirected) match this 1-hop pattern ○ Same as this: (<_|_>|_)
  • 20. © 2019 TigerGraph. All Rights Reserved Simple 1-Hop Pattern (cont.) 20
  • 21. © 2019 TigerGraph. All Rights Reserved 21
  • 22. © 2019 TigerGraph. All Rights Reserved Repeating a 1-Hop Pattern - Unbounded Variations 22 1. FROM X:x - (E1*) - Y:y ○ X connect to Y via 0 or more repetition of undirected E1. * is called the Kleene star. 2. FROM X:x - (E2>*) - Y:y ○ X connect to Y via 0 or more repetition of rightward E2 3. FROM X:x - (<E3*) - Y:y ○ X connect to Y via 0 or more repetition of leftward E3 4. FROM X:x - (_*) - Y:y ○ X connect to Y via 0 or more undirected edges of any type
  • 23. © 2019 TigerGraph. All Rights Reserved Repeating a 1-Hop Pattern - Unbounded Variations 23 5. FROM X:x - (_>*) - Y:y ○ X connect to Y via 0 or more right-directed edges of any type 6. FROM X:x - (<_*) - Y:y ○ X connect to Y via 0 or more left-directed edges of any type 7. FROM X:x - ((E1|E2>|<E3)*) - Y:y ○ Either E1, E2> or <E3 can be chosen at each repetition.
  • 24. © 2019 TigerGraph. All Rights Reserved Repeating a 1-Hop Pattern - Bounded Variations 24 1. FROM X:x - (E1*2..) - Y:y ○ Lower bounds only. There is a chain of at least 2 E1 edges. 2. FROM X:x - (E2>*..3) - Y:y ○ Upper bounds only. There is a chain of between 0 and 3 E2 edges. 3. FROM X:x - (<E3*3..5) - Y:y ○ Both Lower and Upper bounds. There is a chain of 3 to 5 E3 edges. 4. FROM X:x - ((E1|E2>|<E3)*3) - Y:y ○ Exact bound. There is a chain of exactly 3 edges, where each edge is either E1, E2>, or <E3.
  • 25. © 2019 TigerGraph. All Rights Reserved Repeating a Pattern - Remarks 25 1. Edge aliases cannot be used together with a Kleene star. ○ When an edge is repeated, it would not clear which instance of the edge the alias refers to. 2. Shortest path semantics. ○ When an edge is repeated with the Kleene star, we consider shortest path matches only. ○ Counting and existence check of matched shortest path pattern is tractable.
  • 26. © 2019 TigerGraph. All Rights Reserved 26 Example: Shortest Matching Path In above figure, for the pattern, 1 - (E>*) - 4, the following paths can reach 4 from 1. 1. 1->2->3->4 2. 1->2->3->5->6->2->3->4 (1 loop) 3. Any path 1>2, looping through 2->3->5->6->2 two or more times, and exiting 2>3>4 Only the first one is the shortest, and considered a match for the pattern.
  • 27. © 2019 TigerGraph. All Rights Reserved 27 Specifying How Many Repetitions (cont.)
  • 28. © 2019 TigerGraph. All Rights Reserved 28 Specifying How Many Repetitions (cont.)
  • 29. © 2019 TigerGraph. All Rights Reserved Multiple-Hop Linear Pattern 29 ● 2-hop pattern ○ FROM X:x - (E1:e1) - Y:y - (E2>:e2)-Z:z 1st hop 2nd hop Similarly, a 3-hop pattern concatenates three 1-hop patterns in sequence, every two connecting patterns share one endpoint. Below Y:y and Z:z are the connecting endpoints. ● 3-hop pattern ○ FROM X:x - (E2>:e2) - Y:y - (<E3:e3)- Z:z - (E4:e4) - U:u 1st hop 2nd hop 3rd hop
  • 30. © 2019 TigerGraph. All Rights Reserved Multiple-Hop Linear Pattern 30 ● SELECT Clause ○ select pattern’s endpoints only ○ FROM X:x-(E2>:e2)-Y:y-(<E3:e3)-Z:z-(E4:e4)-U:u; ● FROM Clause ○ FROM pattern can be shortened ■ FROM X:x-(E2>:e2)-Y:y-(<E3:e3)-Z:z-(E4:e4)-U:u ⇒ ■ FROM X:x-(E2>.<E3.E4)-U:u; //note: no alias is allowed for E.E style ● WHERE Clause ○ Conjunction of local hop predicate only ○ Last hop local predicate can refer to the starting end point ○ Kleene star breaks local hop predicate ● ACCUM and POST-ACCUM Clause ○ ACCUM clause executed for each matched instance ○ ACCUM to endpoints only
  • 31. © 2019 TigerGraph. All Rights Reserved How To Use In Upcoming Release 2.4 31 ● Session Parameter ○ set syntax_version="v2" //for pattern match ○ set syntax_version="v1" //default, classic syntax ● Invoke Interpret GSQL Engine ○ INTERPRET QUERY QueryName (p1, p2, ..) //run existing query ○ INTERPRET QUERY () FOR GRAPH graphName { } //adhoc query ● Query Level Syntax Setting ○ CREATE QUERY (p1, p2.,.) Name FOR GRAPH test SYNTAX("v2") { } ○ INTERPRET QUERY () FOR GRAPH test SYNTAX("v1") { }
  • 32. © 2019 TigerGraph. All Rights Reserved Demo Setup 32
  • 33. © 2019 TigerGraph. All Rights Reserved Demo Setup 33 E1 1,003,605 E2 2,052,169 E3 1,003,605 E4 229,166 E5 1,611,869 E6 90,492 E7 2,698,393 E8 713,258 E9 309,766 E10 16,080 E11 1,575 E12 6,380 E13 2,052,169 E14 1,003,605 E15 9,892 E16 1,343 E17 111 E18 70 Total : 3.18M vertices 17.25M edges 11 vertex types 25 edge types Vertex Stats Edge Stats Total comment post compan y university city country continent forum person tag tagclass # attributes 6 8 3 3 3 3 3 3 10 3 3 # vertices 3.18 M 2,052,169 1,003,605 1,575 6,380 1,343 111 6 90,492 9,892 16,080 71 E19 180,623 E20 1,438,418 E21 751,677 E22 1,040,749 E23 1,011,420 E24 7,949 E25 21,654
  • 34. © 2019 TigerGraph. All Rights Reserved Demo Setup 34
  • 35. © 2019 TigerGraph. All Rights Reserved Demo On Docker 35
  • 36. © 2019 TigerGraph. All Rights Reserved Summary 36 Version 2.4 Available End Jun ● Pattern Matching enables ● Demo: Pattern Match Using LDBC Social Network Benchmark Data ○ Interpreted Mode on laptop Docker -- run queries instantly as soon as you write them ● Demo: Pattern Matching in a Recommender Application ○ Interpreted Mode again
  • 37. Q&A Please send your questions via the Q&A menu in Zoom 37
  • 38. © 2019 TigerGraph. All Rights Reserved Developer Edition Available We now offer Docker versions and VirtualBox versions of the TigerGraph Developer Edition, so you can now run on ● MacOS ● Windows 10 ● Linux Developer Edition Download https://www.tigergraph.com/developer/ 38
  • 39. © 2019 TigerGraph. All Rights Reserved NEW! Graph Gurus Developer Office Hours 39 Catch up on previous episodes of Graph Gurus: https://www.tigergraph.com/webinars-and-events/ Every Thursday at 11:00 am Pacific Talk directly with our engineers every week. During office hours, you get answers to any questions pertaining to graph modeling and GSQL programming. https://info.tigergraph.com/officehours
  • 40. © 2019 TigerGraph. All Rights Reserved Additional Resources 40 New Developer Portal https://www.tigergraph.com/developers/ Download the Developer Edition or Enterprise Free Trial https://www.tigergraph.com/download/ Guru Scripts https://github.com/tigergraph/ecosys/tree/master/guru_scripts Join our Developer Forum https://groups.google.com/a/opengsql.org/forum/#!forum/gsql-users @TigerGraphDB youtube.com/tigergraph facebook.com/TigerGraphDB linkedin.com/company/TigerGraph