I have an EDGE “Transfer_Money” from Vertex A to A as A->A. this is directed edge but has no reverse edge.
I know I can traverse it below.
Start = Select s
From Start:s-(Transfer_Money:e)->A:tgt;
Can I also do the other way around ? like
Start = Select s
From **Start:s<-(Transfer_Money:e)-A:tgt;**
This is my requirement because i need to take count of who a person has received money from. I need to count total person who has sent money to that particular person.
but all I can see is below which is not correct since all the arrows are pointing out towards the persons who has transferred money to the one in the middle. it should be the other way around.
pic-3
I would like to see is the output in pic-2. Below is the query if you can help me correct it.
CREATE QUERY AbnormalTransaction() FOR GRAPH MyGraph {
SumAccum<INT> @count = 0;
SetAccum<edge> @evidence, @@edgeSet;
SetAccum<vertex> @@verSet;
Start = {Account.*};
Start = SELECT s
FROM Start:s-(reverse_Transfers_Money:e)-Account:tgt
ACCUM s.@evidence += e,
s.@count += 1;
Start = SELECT s from Start:s
where s.@count >5
ACCUM @@edgeSet += s.@evidence;
PRINT @@edgeSet;
}
Just to confirm you’re only wanting to have the query in TigerGraph Studio give you the visual in picture 2? You’re query appears to be identifying everything correctly and you have ways to glean the related information from it through reverse edges.
However if you just want to have the second visual returned I believe the following should work
SumAccum<INT> @count = 0;
SetAccum<edge> @evidence, @@edgeSet;
SetAccum<vertex> @@verSet;
Start = {Account.*};
suspiciousAccounts = SELECT s
FROM Start:s-(reverse_Transfers_Money:e)-Account:tgt
ACCUM s.@evidence += e,
s.@count += 1
POST-ACCUM
IF s.@count > 5 THEN
@@verSet += s
END;
Start = SELECT s FROM Start:s-(Transfers_Money:e)->Account:tgt
WHERE tgt IN @@verSet
ACCUM @@edgeSet += e;
PRINT @@edgeSet;
@arpan An edge traversal is the same forward as it is back. You just need to specify the edge you would like to traverse in your query. If you have an undirectional edge you can go back and forth on the same edge name. If you have a directional edge you won’t be able to traverse in reverse unless you created a reverse edge during your schema design.