Hi,
How can I get all the edge attributes of an edge. For context, I am trying to customize the tg_cycle for a payment network (e.g. blockchain) and return all the attributes (payment_date, amount) of the @@cycle_list. Trying to add a @@cycles that has the edge attributes.
Cheers
/k
Have you considered using a TUPLE ? You could define the TUPLE and then construct it from any combination of vertex and edge attributes. Post a snippet of code of specifically what you are trying to do.
Thanks Mark. Some details:
The schema is very simple account with directed edge send with attributes date-time and amt. Account has only id. Trying to find cycles which are indicative of Money Laundering in the domain of blockchain forensics.
- Modified the tg_cycle_detection and it works (I have a set of test graphs and associated tiny dataset)
- Now to get payment edges - here is my code. Couldn’t find a way of dereferencing the results from the cycle detection to find the edges - say it returns “cycles”: [
[
“107”,
“106”,
“101”
], I want to get the edges 101-106, 106-107 and 107-101
CREATE QUERY order_payment_cycle(/* Parameters here /) FOR GRAPH Tumbler {
ListAccum<ListAccum> @@cycles_list;
ListAccum<ListAccum> @@edges_list;
ListAccum @@edges;
// VERTEX s_node, t_node;
@@cycles_list = rt_cycle();
FOREACH c_list IN @@cycles_list DO
PRINT(c_list);
FOREACH i IN RANGE[0, c_list.size() - 1] DO
PRINT(c_list.get(i));
Start = {account.};
s_node = SELECT s FROM Start:s WHERE s == c_list.get(i);
t_node = SELECT s FROM Start:s WHERE s == c_list.get(i+1);
res = SELECT s FROM s_node:s - (send:e) → account:tgt
WHERE tgt.id == t_node.id
ACCUM
@@edges += e;
PRINT(@@edges);
END;
@@edges_list += @@edges;
END;
PRINT(@@cycles_list);
PRINT(@@edges_list);
}
BTW, this is for the TG challenge - finding camouflaged fraud rings in blockchain.
Hi,
I simplified the code. (I think I am getting a hang of the GSQL!) The challenge is object type conversion - does GSQL support casting objects ?
CREATE QUERY ops_02(/* Parameters here /) FOR GRAPH Tumbler {
ListAccum<ListAccum> @@cycles_list;
ListAccum<ListAccum> @@edges_list;
ListAccum @@edges;
// VERTEX s_node, t_node;
@@cycles_list = rt_cycle();
FOREACH c_list IN @@cycles_list DO
// PRINT(c_list);
Start = {c_list};
res = SELECT s FROM Start:s - (send:e) → account:tgt
WHERE tgt IN c_list ← ** This won’t work
ACCUM
@@edges += e;
PRINT(@@edges);
@@edges_list += @@edges;
END;
// PRINT(@@cycles_list);
// PRINT(@@edges_list);
}
Cheers
/k
Hi,
I have refined it further - and learning more about GSQL. The challenge is that neither the where or having is happy with an IN statement. Would appreciate pointers/ideas :
CREATE QUERY ops_02(/* Parameters here */) FOR GRAPH Tumbler {
ListAccum<ListAccum<VERTEX>> @@cycles_list;
ListAccum<ListAccum> @@edges_list;
ListAccum @@edges;
// VERTEX s_node, t_node;
@@cycles_list = rt_cycle();
FOREACH c_list IN @@cycles_list DO
PRINT(c_list);
Start = {c_list};
res = SELECT s FROM Start:s - (send:e) → account:tgt
//WHERE tgt IN [c_list]
ACCUM
@@edges += e
//HAVING tgt IN [c_list]
;
//PRINT(@@edges);
@@edges_list += @@edges;
END;
// PRINT(@@cycles_list);
PRINT(@@edges_list);
}
I have done many similar queries to yours, but I have always used either
SET<VERTEX> targets
or
SetAccum<VERTEX> @@targetSet;
Both of these allow to use the set in an IN clause. So I think your issue is that you are using a ListAccum . Should be fairly simple to modify your logic to produce a SET.
Mark,
Excellent & Thanks. It worked & I am unblocked !! Of course, no good deed goes unpunished - now I have more interesting issues - will pester with more questions.
Cheers & Thanks
/k