How can I extract edges of different types

I can print all the vertices even if they have different types:

CREATE QUERY allvertices() FOR GRAPH gr1 SYNTAX v2 {
allVertices = {ANY};
PRINT allVertices;
if I try the simpliest query to see all edges


allVertices = {ANY};
allEdges = SELECT e
            FROM allVertices:s - (:e) - allVertices:s2;
PRINT allEdges;


I have error

Type Check Error in query qc2_alledges (TYP-8017): line 8, col 15
no type can be inferred for SELECT e
FROM allVertices:s - (:e) - allVertices:s2

Even if I try to see only one edge, I have the same problem

CREATE QUERY qc2_edges() FOR GRAPH social SYNTAX v2 {

allVertices = {vertexname.*};
allEdges = SELECT e
            FROM allVertices:s - (edgename:e) - person:s2;
PRINT allEdges;


Is there a simple way in gsql to extract edges?
I know only variant in gsql shell
select * from vertexname-(edgename)-vertexname2
But how can I extract edges of different types?
Thank you

1 Like

@tigergraphuser my recommendation is using an Accumulator function. Below I’ve used the ListAccum to “accumulate” edges.

Example 1:

  ListAccum <EDGE> @@edgeList;
  seed =  {vertex.*};
  myEdges = SELECT tgt 
            FROM seed:s-(myEdge:e)-:tgt
            ACCUM @@edgeList += e;
  PRINT @@edgeList;

If you’re looking to do a combination of edges you could do something like this.

Example 2:

CREATE QUERY getEdges() FOR GRAPH myGraph { 
  ListAccum <EDGE> @@edgeList1;
  ListAccum <EDGE> @@edgeList2;
  ListAccum <EDGE> @@edgeList3;

  seed1 =  {vertex1.*};
  seed2 =  {vertex2.*};

  myEdges1 = SELECT tgt 
             FROM seed1:s-(myEdge1:e)-:tgt
             ACCUM @@edgeList1 += e;
  myEdges2 = SELECT tgt 
             FROM seed1:s-(myEdge2:e)-:tgt
             ACCUM @@edgeList2 += e;  

 myEdges3 = SELECT tgt 
            FROM seed2:s-(myEdge3:e)-:tgt
            ACCUM @@edgeList3 += e;  

 PRINT @@edgeList1, @@edgeList2, @@edgeList3;


Documentation link to ListAccum

Thank you for your answer. It is a reliable way to use Accumulators for this purpose but if I do not now how many edge types are there in my graph?

With TigerGraph you need to have a schema. With a Schema you should know all the edges that exist.

You could use ANY like you were doing and have a huge edge list of all edges.

Thank you! I’ll try to get the list of all my edges in that way

1 Like