Last active
May 30, 2020 06:18
-
-
Save vladbatushkov/de77813eb05f9ccecc9339733569d9ad to your computer and use it in GitHub Desktop.
Sub-graph for money graph, that connects Transactions via HOPs
This file contains hidden or 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
// clean up HOPS | |
CALL apoc.periodic.iterate( | |
"MATCH (:Transaction)-[r:HOP]->(:Transaction) RETURN r", | |
"DETACH DELETE r", | |
{ batchSize: 10000, parallel: false }); | |
// generate HOP relationships | |
CALL apoc.periodic.iterate( | |
"MATCH (t1:Transaction)<-[:IN]-(e)-[:OUT]->(t2:Transaction) | |
WHERE (e:Client OR e:Company) | |
AND t1.timestamp < t2.timestamp | |
AND t2.amount < t1.amount | |
AND (t1.amount - t2.amount) / t1.amount < 0.25 | |
RETURN t1, t2", | |
"MERGE (t1)-[:HOP]->(t2)", | |
{ batchSize: 10000, parallel: false }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment