Search code examples
python-2.7timeneo4jpy2neo

Why there are same node in path in my query in neo4j?


There is cypher sql like this:

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

Then it's return:

{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)}

There is a ring in my path and how to avoid this condition.

Finally why my query is so solw and query a path under in 10 depth will spend about 1000s-2500s.

There is my config:

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

Solution

  • Perhaps you meant to specify a path of between 1 and 6 hops, rather than exactly six:

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