neo4j - relationship types in py2neo -


how can can type of relationship cypher query in py2neo? have piece of code works.

def print_row(row):     a,b = row     print (a["name"] + " " + b["name"])  cypher.execute(graph_db, "start a=node(1) match (a) - [] - (b)  return a,b", row_handler=print_row)  

this way can print out nodes connected input node (1).

rock paper rock scissors 

however print type of relationship these nodes have.

for instance:

rock beats scissors rock beaten_by paper 

what tried (and failed) follows:

def print_row(row):     a,b,r = row     print (a["name"] + r["type"] + b["name"])  cypher.execute(graph_db,"start a=node(1) match (a) -[r]->(b) return a,b,r", row_handler=print_row) 

how can py2neo?

you need use cypher type function (http://docs.neo4j.org/chunked/milestone/query-functions-scalar.html#functions-type). code this:

def print_row(row):     a, r_type, b = row     print(a["name"] + " " + r_type + " " + b["name"])  cypher.execute(graph_db, "start a=node(1) match (a)-[r]->(b) return a, type(r), b", row_handler=print_row) 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -