Skip to content

Instantly share code, notes, and snippets.

@kshefchek
Created July 6, 2018 22:49
Show Gist options
  • Select an option

  • Save kshefchek/3bca6db792164e4749cf50fea9562dbd to your computer and use it in GitHub Desktop.

Select an option

Save kshefchek/3bca6db792164e4749cf50fea9562dbd to your computer and use it in GitHub Desktop.
Creating meta graphs for monarch-lite
CALL apoc.periodic.iterate(
"MATCH (a)-[r]->(b)
WITH FILTER(lab in labels(a)
WHERE (
lab <> 'Class' AND
lab <> 'NamedIndividual' AND
lab <> 'Node' AND
lab <> 'cliqueLeader'
)) AS a_labels,
type(r) AS rel_type,
FILTER(lab in labels(b)
WHERE (
lab <> 'Class' AND
lab <> 'NamedIndividual' AND
lab <> 'Node' AND
lab <> 'cliqueLeader'
)) AS b_labels
UNWIND a_labels as l
UNWIND b_labels as l2
RETURN l, l2, rel_type",
"MERGE (a:Node:Meta {name:l})
MERGE (b:Node:Meta {name:l2})
MERGE (a)-[:OUTGOING]->(:Relationship:Meta {name:rel_type})-[:INCOMING]->(b)",
{batchSize:1000, parallel:false, iterateList:true}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment