Last active
November 25, 2017 16:35
-
-
Save tomasonjo/cdd182c53250dc1ab07be2156db43f2d to your computer and use it in GitHub Desktop.
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
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:///paradise_papers.nodes.officer.csv" as row | |
MERGE (n:Node{id:row.`n.node_id`}) | |
SET n:Officer | |
SET n.service_provider = row.`n.service_provider`, | |
n.jurisdiction_description = row.`n.jurisdiction_description`, | |
n.status = row.`n.status`, | |
n.country_codes = row.`n.country_codes`, | |
n.type = row.`n.type`, | |
n.note = row.`n.type`, | |
n.company_type = row.`n.company_type`, | |
n.address = row.`n.address`, | |
n.valid_until = row.`n.valid_until`, | |
n.incorporation_date = row.`n.incorporation_date`, | |
n.closed_date = row.`n.closed_date`, | |
n.countries = row.`n.countries`, | |
n.name = row.`n.name` | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:///paradise_papers.nodes.entity.csv" as row | |
MERGE (n:Node{id:row.`n.node_id`}) | |
SET n:Entity | |
SET n.service_provider = row.`n.service_provider`, | |
n.jurisdiction_description = row.`n.jurisdiction_description`, | |
n.status = row.`n.status`, | |
n.country_codes = row.`n.country_codes`, | |
n.type = row.`n.type`, | |
n.note = row.`n.type`, | |
n.company_type = row.`n.company_type`, | |
n.address = row.`n.address`, | |
n.valid_until = row.`n.valid_until`, | |
n.incorporation_date = row.`n.incorporation_date`, | |
n.closed_date = row.`n.closed_date`, | |
n.countries = row.`n.countries`, | |
n.name = row.`n.name`, | |
n.jurisdiction = row.`n.jurisdiction` | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:///paradise_papers.nodes.intermediary.csv" as row | |
MERGE (n:Node{id:row.`n.node_id`}) | |
SET n:Intermediary | |
SET n.service_provider = row.`n.service_provider`, | |
n.jurisdiction_description = row.`n.jurisdiction_description`, | |
n.status = row.`n.status`, | |
n.country_codes = row.`n.country_codes`, | |
n.type = row.`n.type`, | |
n.note = row.`n.type`, | |
n.company_type = row.`n.company_type`, | |
n.address = row.`n.address`, | |
n.valid_until = row.`n.valid_until`, | |
n.incorporation_date = row.`n.incorporation_date`, | |
n.closed_date = row.`n.closed_date`, | |
n.countries = row.`n.countries`, | |
n.name = row.`n.name`, | |
n.jurisdiction = row.`n.jurisdiction` | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:///paradise_papers.edges.csv" as row | |
MERGE (n1:Node{id:row.node_1}) | |
MERGE (n2:Node{id:row.node_2}) | |
WITH n1,n2,row | |
CALL apoc.merge.relationship(n1,toUPPER(row.rel_type),{},{}, n2) yield rel | |
return distinct "done" | |
CALL apoc.periodic.iterate( | |
"MATCH (p1:Officer)-->(:Entity)<--(p2:Officer) where id(p1) < id(p2) RETURN p1,p2", | |
"MERGE (p1)-[r:RELATED]-(p2) ON CREATE SET r.weight = 1 ON MATCH SET r.weight = r.weight + 1" | |
, {batchSize:5000, parallel:false,iterateList:true}) |
MATCH (e:Entity)
WHERE e.closed_date <> ""
SET e:Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MATCH ()-[k:RELATED]->()
RETURN (k.weight / 10) * 10 as weight,count(*) as count
ORDER BY count DESC LIMIT 20
CALL apoc.stats.degrees('RELATED') yield type, direction, total, min, max, mean, p50, p75, p90, p95, p99, p999
CALL algo.unionFind('Officer', 'RELATED',
{weightProperty:'weight', threshold:10.0,concurrency:1,partitionProperty:'component'})
YIELD computeMillis
MATCH path = (:Officer{partition:644})-[r:RELATED]->(:Officer{partition:644})
WHERE r.weight > 10
CALL apoc.gephi.add(null,'workspace1',path,'weight') yield nodes
return distinct "done"