intermediateNeo4j — Graph Database & Cypher Queries
Your fraud detection team wants to identify accounts that are part of a ring of money transfers (circular transactions). How do you implement this in Neo4j?
MATCH cycle = (account:Account)-[:TRANSFERRED_TO*3..7]->(account) WHERE all(rel IN relationships(cycle) WHERE rel.amount > 5000 AND rel.timestamp > datetime()-duration('P7D')) WITH account, length(cycle) AS cycleLength, [r IN relationships(cycle) | r.amount] AS amounts RETURN DISTINCT account.accountNumber, cycleLength, reduce(total=0, a IN amounts | total + a) AS totalMoneyInCycle ORDER BY totalM
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response