Hi,
I am attempting to write a query with a rather complicated series of hops and I can’t seem to figure out how to make it happen properly. In a nutshell, I would like to join multiple times against the same vertex set. Here’s a diagram of an example schema, query, and data set that will help illustrate my question:
In the above system I would like to write a query that will find vertex “A” while enforcing all of the required patterns specified in the query. To state the query in natural language terms:
- Find all vertices that each satisfy all of:
- Source of an edge of type e1 that targets a vertex with all of:
- An edge of type e1 that targets any vertex
- An edge of type e2 that targets any vertex
- An edge of type e3 that targets any vertex
- Source of an edge of type e2 that targets a vertex with all of:
- An edge of type e2 that targets any vertex
- An edge of type e3 that targets any vertex
- An edge of type e4 that targets any vertex
- Source of an edge of type e3 that targets a vertex with all of:
- An edge of type e3 that targets any vertex
- An edge of type e4 that targets any vertex
- An edge of type e5 that targets any vertex
- Source of an edge of type e1 that targets a vertex with all of:
The trouble I run into is how to chain together the multi-hop patterns necessary to satisfy the requirements. Is a query like this even possible in TigerGraph? In SQL I would write something like:
SELECT DISTINCT id
FROM vertex_t1
JOIN edge_e1 AS e1a1 ON vertex_t1.id = e1a1.source
JOIN edge_e1 AS e1a2 ON e1a1.target = e1a2.source
JOIN edge_e2 AS e2a ON e1a1.target = e2a.source
JOIN edge_e3 AS e3a ON e1a1.target = e3a.source
JOIN edge_e2 AS e2b1 ON vertex_t1.id = e2b1.source
JOIN edge_e2 AS e2b2 ON e2b1.target = e2b2.source
JOIN edge_e3 AS e3b ON e2b1.target = e3a.source
JOIN edge_e4 AS e4b ON e2b1.target = e4a.source
JOIN edge_e3 AS e3c1 ON vertex_t1.id = e3c1.source
JOIN edge_e3 AS e3c2 ON e3c1.target = e3c2.source
JOIN edge_e4 AS e4c ON e3c1.target = e4c.source
JOIN edge_e5 AS e5c ON e3c1.target = e5c.source
Thanks in advance for any light you can shed!