Last active
September 20, 2023 14:14
-
-
Save halftermeyer/4841ef76830fa58a03f8d62c8d760d88 to your computer and use it in GitHub Desktop.
Cypher pre-v5 fraud ring detection query
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 | |
AND tx[idx].amount >= tx[idx+1].amount >= 0.80 * tx[idx].amount | |
) | |
// Return all paths | |
RETURN path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment