Hello,
I am looking at getting all instances of the following two patterns on a particular input graph using TigerGraph.
(a)>(b), (b)>©, (a)>© & (a)>(b), (b)>(d), (a)>©, ©>(d)
My goal is to return the tuples of each i.e. [a, b, c] and [a,b,c,d] or any ordering that TigerGraph would allow for.
I am unclear on how to deal with cyclic queries using GSQL.
Thank you,
Amine.
Hi Amine,
Can you provide more details on the description of the problem?

What is a, b, c, d? Four vertex id or vertex type?

what does the following patterns mean
(a)>(b), (b)>©, (a)>© & (a)>(b), (b)>(d), (a)>©, ©>(d)
We usually describe the path pattern as a chain with vertex type and edge type for each step, i.e. a(e1)>b(e2)>c(e3)>d, indicating a path with starting vertex type a and then followed the edge type e1 arriving at vertex type b, and then following edge type e2 arriving at vertex type c and …
Best Wishes,
Dan
 so a,b, c, d are variable names where each one of them will map to a vertex Id.
In those patterns, my goal is to not add types.
 I am able to run path queries but I am interested in non path queries. How do I close the loop.
That is how would I implement the following a(e1)>b(e2)>c(e3)>a?
Hi Amine,
In your graph pattern matching problem, are you using isomorphism semantic or homomorphism semantic? Or more specifically, in the pattern (a)>(b)>©<(a), can b and c be matched to the same vertex, or they have to be matched to different vertices?
Best,
Renchu
My datasets do not have self loops so b and c cannot be matched to the same vertex id.
Hi Amine,
Here is one possible implementation for your 1st pattern: (a)>(b), (b)>(c), (a)>(c). This implementation uses query calling query feature, and is not necessarily the optimal implementation:
CREATE QUERY onePatternABC(vertex a) FOR GRAPH AntiFraud returns (ListAccum<ListAccum>) {
ListAccum<ListAccum> @@result;
ListAccum @edgeFromA;
OrAccum @visited;
A = { a };
BorC = select tgt
from A (:e)> :tgt
accum tgt.@edgeFromA += e, tgt.@visited = true;
C = select c
from BorC:b (:e)> :c
where c.@visited
accum @@result += [b.@edgeFromA.get(0), e, c.@edgeFromA.get(0)];
return @@result;
}
CREATE QUERY allPatternsABC() FOR GRAPH AntiFraud {
ListAccum<ListAccum> @@result;
A = { any };
AllA = select a
from A:a
accum @@result += onePatternABC(a);
print @@result;
}
Here is the query result of a sample graph:
Best,
Renchu