Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python py2neo在现有节点之间建立新边_Python_Neo4j_Cypher_Py2neo_Edges - Fatal编程技术网

Python py2neo在现有节点之间建立新边

Python py2neo在现有节点之间建立新边,python,neo4j,cypher,py2neo,edges,Python,Neo4j,Cypher,Py2neo,Edges,假设我想将新的边合并到两个相邻节点之间的图中(这样,在操作之后,可以说有问题的边加倍) 我有graph.cypher.execute()返回的以下记录: 现在我想把边(A,B)和(B,C)加倍。为此,我编写了以下代码: for record in graph.cypher.execute(<some query>): for rel in record[0]: self.graph.cypher.execute("MERGE "+str(self.gr

假设我想将新的边合并到两个相邻节点之间的图中(这样,在操作之后,可以说有问题的边加倍)

我有
graph.cypher.execute()
返回的以下记录:

现在我想把边(A,B)和(B,C)加倍。为此,我编写了以下代码:

for record in graph.cypher.execute(<some query>):
    for rel in record[0]:
            self.graph.cypher.execute("MERGE "+str(self.graph.node(rel.start_node.ref))+"-[:new]->"+str(self.graph.node(rel.end_node.ref)))
用于graph.cypher.execute()中的记录:
对于记录[0]中的rel:
self.graph.cypher.execute(“MERGE”+str(self.graph.node(rel.start\u node.ref))+“-[:new]->”+str(self.graph.node(rel.end\u node.ref)))
但是,我没有在现有节点之间获得新的边,而是获得了两个新的关系,总共有4个新节点,因为显然NEO4J不会将
str(self.graph.node(rel.start_node.ref))
str(self.graph.node(rel.end_node.ref))
解释为图中的现有节点。我怎样才能解决这个问题呢?

self.graph.create(rel(r.start\u节点,“new”,r.end\u节点))做到了

需要py2neo导入rel中的

for record in graph.cypher.execute(<some query>):
    for rel in record[0]:
            self.graph.cypher.execute("MERGE "+str(self.graph.node(rel.start_node.ref))+"-[:new]->"+str(self.graph.node(rel.end_node.ref)))