Skip to content

Instantly share code, notes, and snippets.

@MattBlissett
Last active December 28, 2015 16:29
Show Gist options
  • Save MattBlissett/7529701 to your computer and use it in GitHub Desktop.
Save MattBlissett/7529701 to your computer and use it in GitHub Desktop.
Neo4j GraphGist experiment, planned to show Kew's SHS Names and Taxonomy Backbone names and concept data model.
//console
[source,cypher]
----
MERGE (f:Name { name:'Fagaceae' })
MERGE (q:Name { name:'Quercus' })
MERGE (qa:Name { name:'Quercus alba' })
MERGE (qrep:Name { name:'Quercus repanda' })
MERGE (qr:Name { name:'Quercus robur' })
MERGE (ql:Name { name:'Quercus longaeva' })
MERGE (qp:Name { name:'Quercus pedunculata' })
CREATE UNIQUE (q)-[:CHILD_OF{accordingTo:'wc'}]->(f)
CREATE UNIQUE (qa)-[:CHILD_OF{accordingTo:'wc'}]->(q)
CREATE UNIQUE (qr)-[:CHILD_OF{accordingTo:'wc'}]->(q)
CREATE UNIQUE (ql)-[:SUPERFLUOUS_NAME_OF{accordingTo:'ipniSoon'}]->(qr)
CREATE UNIQUE (qrep)-[:SYNONYM_OF{accordingTo:'wc'}]->(qa)
CREATE UNIQUE (qp)-[:SYNONYM_OF{accordingTo:'tropicos'}]->(qr)
----
Next, find relationships Tropicos has that WCSP doesn't.
[source,cypher]
----
MATCH p=(n:Name)-[r]->(t:Name)
WHERE ANY (y IN rels(p) WHERE y.accordingTo='tropicos')
AND NOT ANY (x IN rels(p) WHERE x.accordingTo = 'wc')
RETURN n, r, t
----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment