Skip to content

Instantly share code, notes, and snippets.

@rwblair
Created April 25, 2017 05:36
Show Gist options
  • Save rwblair/88b36170002a05ff6fab282bd7e8c269 to your computer and use it in GitHub Desktop.
Save rwblair/88b36170002a05ff6fab282bd7e8c269 to your computer and use it in GitHub Desktop.
from py2neo import Graph, Node, Relationship
graph = Graph("http://192.168.99.100:7474/db/data/")
# list all concepts
def list_concepts():
concepts = graph.cypher.execute("MATCH (c:concept) RETURN c")
return concepts
concepts = list_concepts()
for concept in concepts:
print(concept.properties)
# all parent concepts
def parent_concepts(id):
parents = graph.cypher.execute("MATCH (parent:concept)-[:KINDOF]->(child:concept) WHERE child.id='{}' RETURN parent".format(id))
return parents
# get contrasts measured by concept
def get_contrasts(id):
contrasts = graph.cypher.execute("MATCH (concept:concept)-[:MEASUREDBY]->(contrast:contrast) WHERE concept.id='{}' RETURN contrast".format(id))
return contrasts
# return [x.properties for x in contrasts]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment