USE GRAPH financialGraph # create a query CREATE OR REPLACE QUERY q5() SYNTAX v3 { //Define a custom tuple to store the vertex pairs and their distance TYPEDEF TUPLE pair; //Declare a global heap accumulator to store the top 2 similar pairs HeapAccum(2, distance ASC) @@result; // a path pattern in ascii art () -[]->()-[]->() v = SELECT b FROM (a:Account)-[e:transfer]->()-[e2:transfer]->(b:Account) ACCUM @@result += pair(a, b, gds.vector.distance(a.emb1, b.emb1, "COSINE")); PRINT @@result; } #compile and install the query as a stored procedure install query q5 #run the query run query q5()