I have a python function that adds nodes and relationship to the graph.
I have added the nodes and relationship using graph.cypher.execute().
arr_len = len(dic_st[story_id]['PER'])
for j in dic_st[story_id]['PER']:
graph.cypher.execute("MERGE (n:PER {name:{name}})",name = j[0].upper())
#creating the nodes of PER in the story
print j[0]
for j in range(0,arr_len):
for k in range(j+1,arr_len):
graph.cypher.execute("MATCH (p1:PER {name:{name1}}), (p2:PER
{name:{name2}}) WHERE upper(p1.name)<>upper(p2.name) CREATE UNIQUE
(p1)-[r:in_same_doc {st_id:{st_id}}]-(p2)", name1=dic_st[story_id]['PER'][j
][0].upper(),name2=dic_st[story_id]['PER'][k][0].upper(),st_id=story_id)
#linking the edges for PER nodes
What I need is to return the number of new nodes and relationships created
from the function.
What I get to know from the neo4j documentation is that there is something
called "ON CREATE" and "ON MATCH" for MERGE in cypher, but that’s not being
very useful. The browser interface for neo4j do actually shows the number
of nodes and relationship updated. This is what I need to return, but I am
not getting quite the way for it to access it through cypher.
Any idea about it.....
<https://lh3.googleusercontent.com/-XgW4g67BBwg/VUmfwGK7uaI/AAAAAAAAALk/c7bBi86T2TU/s1600/Screenshot%2Bfrom%2B2015-05-06%2B10%3A26%3A59.png>
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.