Last active
May 30, 2020 05:33
-
-
Save vladbatushkov/22828e572eee1ce2e2a85f14b92f17d5 to your computer and use it in GitHub Desktop.
Generate graph of Finance Transactions
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 | |
CALL apoc.periodic.iterate( | |
"MATCH (n) RETURN n", | |
"DETACH DELETE n", | |
{ batchSize: 10000, parallel: true }); | |
// generate Entities | |
CALL apoc.generate.er(500000, 5000000, 'Client', 'TRANSFER_TO'); | |
// select ATMs | |
MATCH (c:Client) | |
WITH c | |
LIMIT 5000 | |
SET c:Atm | |
REMOVE c:Client; | |
// delete Transfers from ATM | |
MATCH (a:Atm)-[t:TRANSFER_TO]->() | |
DETACH DELETE t; | |
// select Companies | |
MATCH (c:Client) | |
WHERE NOT c:Atm | |
WITH c | |
LIMIT 50000 | |
SET c:Company | |
REMOVE c:Client; | |
// generate Transactions | |
CALL apoc.periodic.iterate( | |
"MATCH (e1)-[:TRANSFER_TO]->(e2) RETURN e1, e2, round(rand() * 1000) as value", | |
"CREATE (e1)-[:OUT]->(:Transaction { timestamp: dateTime() - duration({ minutes: toInteger(value * 10) }), amount: value })<-[:IN]-(e2)", | |
{ batchSize: 10000, parallel: false }); | |
// remove TRANSFER_TO | |
CALL apoc.periodic.iterate( | |
"MATCH ()-[t:TRANSFER_TO]->() RETURN t", | |
"DETACH DELETE t", | |
{ batchSize: 10000, parallel: false }); | |
// create indexes | |
// DROP INDEX ON :Transaction(amount); DROP INDEX ON :Transaction(timestamp); | |
CREATE INDEX ON :Transaction(amount); | |
CREATE INDEX ON :Transaction(timestamp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment