Created
August 19, 2019 18:40
-
-
Save maxdemarzi/ec751763df5df582786ceb69a7a69880 to your computer and use it in GitHub Desktop.
Fighting Fraud with Neo4j part 2
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
MATCH (n:User) | |
RETURN n.partition, COUNT(*) AS members, COLLECT(n.name) AS names | |
ORDER BY members DESC | |
LIMIT 10 |
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
CREATE (john:User {name:"John"}) | |
CREATE (sheila:User {name:"Sheila"}) | |
CREATE (karen:User {name:"Karen"}) | |
CREATE (ba1:Account {number:"85474584", balance:1322.30, type:"Checking"}) | |
CREATE (ba2:Account {number:"25384738", balance:2983.99, type:"Checking"}) | |
CREATE (ba3:Account {number:"63493639", balance:3204.83, type:"Checking"}) | |
CREATE (john)-[:HAS_ACCOUNT]->(ba1) | |
CREATE (sheila)-[:HAS_ACCOUNT]->(ba2) | |
CREATE (karen)-[:HAS_ACCOUNT]->(ba3) | |
CREATE (us1:Loan {number:"63493639", balance:5000.00, rate: 5.8, type:"Unsecured Loan"}) | |
CREATE (us2:Loan {number:"28372342", balance:5000.00, rate: 6.0, type:"Unsecured Loan"}) | |
CREATE (john)-[:HAS_ACCOUNT]->(us1) | |
CREATE (karen)-[:HAS_ACCOUNT]->(us2) | |
CREATE (cc1:Card {number:"4012888888881881", balance: 493.23}) | |
CREATE (cc2:Card {number:"5105105105105100", balance: 893.11}) | |
CREATE (john)-[:HAS_ACCOUNT]->(cc1) | |
CREATE (sheila)-[:HAS_ACCOUNT]->(cc2) | |
CREATE (phone1:Phone {number:"312-876-5309"}) | |
CREATE (phone2:Phone {number:"312-606-0842"}) | |
CREATE (john)-[:HAS_PHONE]->(phone1) | |
CREATE (sheila)-[:HAS_PHONE]->(phone1) | |
CREATE (karen)-[:HAS_PHONE]->(phone2) | |
CREATE (ssn1:Identification {number:"000-91-7434", type:"SSN"}) | |
CREATE (ssn2:Identification {number:"000-42-4329", type:"SSN"}) | |
CREATE (john)-[:HAS_ID]->(ssn1) | |
CREATE (karen)-[:HAS_ID]->(ssn1) | |
CREATE (sheila)-[:HAS_ID]->(ssn2) | |
CREATE (ad:Address {line1:"175 N. Harbor Drive", city:"Chicago", state:"IL", zip:"60601"}) | |
CREATE (john)-[:HAS_ADDRESS]->(ad) | |
CREATE (karen)-[:HAS_ADDRESS]->(ad) | |
CREATE (sheila)-[:HAS_ADDRESS]->(ad) | |
CREATE (robert:User {name:"Robert"}) | |
CREATE (ba4:Account {number:"8374927", balance:1273.39, type:"Checking"}) | |
CREATE (cc3:Card {number:"378282246310005", balance: 134.72}) | |
CREATE (robert)-[:HAS_ACCOUNT]->(ba4) | |
CREATE (robert)-[:HAS_ACCOUNT]->(cc3) |
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
MATCH (john:User {name:"John"}), (sheila:User {name:"Sheila"}) | |
CREATE (ani:ANI {number:"312-666-1234"}) | |
CREATE (ani)-[:ACCESSED]->(john) | |
CREATE (ani)-[:ACCESSED]->(sheila); | |
MATCH (john:User {name:"John"}), (robert:User {name:"Robert"}) | |
CREATE (fg:Browser {fingerprint:"asdf7373jsdf3rw"}) | |
CREATE (fg)-[:ACCESSED]->(john) | |
CREATE (fg)-[:ACCESSED]->(robert); |
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
CALL algo.unionFind.stream( | |
'MATCH (p:User) RETURN id(p) as id', | |
'MATCH (p1:User)-->()<--(p2:User) | |
RETURN id(p1) as source, id(p2) as target', | |
{graph:'cypher'} | |
) YIELD nodeId, setId | |
RETURN algo.asNode(nodeId).name AS user, setId |
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
CALL algo.unionFind.stream( | |
'MATCH (p:User) RETURN id(p) as id', | |
'MATCH (p1:User)<-[:ACCESSED]-()-[:ACCESSED]->(p2:User) | |
RETURN id(p1) as source, id(p2) as target', | |
{graph:'cypher'} | |
) YIELD nodeId, setId | |
RETURN algo.asNode(nodeId).name AS user, setId |
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
CALL algo.unionFind.stream( | |
'MATCH (p:User) RETURN id(p) as id', | |
'MATCH (p1:User)--()--(p2:User) | |
RETURN id(p1) as source, id(p2) as target', | |
{graph:'cypher'} | |
) YIELD nodeId, setId | |
RETURN algo.asNode(nodeId).name AS user, setId |
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
CALL algo.unionFind( | |
'MATCH (p:User) RETURN id(p) as id', | |
'MATCH (p1:User)--()--(p2:User) | |
RETURN id(p1) as source, id(p2) as target', | |
{graph:'cypher'} | |
) YIELD setCount |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment