为什么在neo4j的查询中路径中存在相同的节点?

时间:2018-12-29 03:41:49

标签: python-2.7 time neo4j py2neo

有这样的密码sql:

match p=(:Devices{name:"123.123.123.123"})-[r:Cost*..6]->(:Devices{name:"123.123.123.124"}) with p return p;

然后返回:

{u'p': (123.123.123.123)-[:Cost {Cost: 21}]->(123.123.123.120)-[:Cost {Cost: 92}]->(123.123.123.110)-[:Cost {Cost: 82}]->(123.123.123.119)-[:Cost {Cost: 91}]->(123.123.123.123)-[:Cost {Cost: 56}]->(123.123.123.130)-[:Cost {Cost: 24}]->(123.123.123.124)}

我的路径上有环,以及如何避免这种情况。

最后为什么我的查询如此求索和查询 在10深度以下的路径将花费大约1000s-2500s。

有我的配置:

dbms.memory.heap.initial_size=4096m
dbms.memory.heap.max_size=9192m
dbms.memory.pagecache.size=10g
dbms.threads.worker_count=16

1 个答案:

答案 0 :(得分:0)

也许您打算指定1到6个跃点之间的路径,而不是确切地指定6个跃点:

match p=(:Devices{name:"123.123.123.123"})-[r:Cost*1..6]->
  (:Devices{name:"123.123.123.124"}) with p return p;