This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Anchoring the following QPP to a first transaction | |
MATCH (a:Account)<-[f:FROM]-(first_tx:Transaction) | |
// matching a Neo4j 5.9+ QPP with + cardinality (1 or more) | |
MATCH path=(a)<-[f]-(first_tx) | |
( | |
(tx_i:Transaction)-[:TO]->(a_i:Account)<-[:FROM]-(tx_j:Transaction) | |
// inner-qpp locally-defined rules filtering | |
WHERE tx_i.date < tx_j.date | |
AND tx_i.amount >= tx_j.amount >= 0.80 * tx_i.amount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Produce any 2-to-6-hop-long path | |
MATCH path=(a:Account)-[rel:TRANSACTION*2..6]->(a) | |
// Then filter to keep only | |
// - non-node-repeating paths (using some APOC magic) | |
WHERE size(apoc.coll.toSet(nodes(path))) = size(nodes(path)) - 1 | |
// - and, at each step… | |
AND ALL(idx in range(0, size(rel)-2) | |
// … date-consistent | |
WHERE (rel[idx]).date < (rel[idx+1]).date | |
// … and 20%-rule compliant paths |