Check if graph contains a given edge

Let’s say I have the following list of edges declared somewhere in my GSQL query:

ListAccum<EDGE> @@edges;

which is later populated with edges.

Is it possible to iterate over this list with a FOREACH loop, asking for every edge whether it exists in the graph or not?

Thanks in advance.


Yes this is possible and can be done approximately as follows:

ListAccum<EDGE> @@ans;
INT status;


FOREACH singleEdge IN @@ans DO
    status = 0;
    all = {ANY};
    check = SELECT s FROM all:s - (:e) - :t 
            ACCUM if e == singleEdge then status = 1 end;
    if status == 1 then
      print singleEdge;

However, I can’t help but wonder how you plan on populating @@edges with “fake” edges that don’t actually exist in the graph?

Thanks a lot for your answer.

The thing is that I want to implement this algorithm in GSQL to find all 3-cliques in the graph:

As can be seen in the pseudocode, some edges need to be generated to later check if they exist or not.

By a 3-clique, did you mean a triangle?
Or a 4-vertex set connected to the other 3?
We have algorithms to count the triangles. This can be modified to report the triangles.

We also have a k-core algorithm (more general than k-cliques) which could be refined to look only for k-cliques. If you want k > 3, then that would be the approach.