0

I have got nodes connected like in the picture from the link

I do query START a=node(27), b=node(0) MATCH p=b<-[*]-a RETURN p

I expect that I will get 3 paths but got 6. First 3 are correct but the last 3 have got duplicate 'node 0'

For example:

correct path: 0 -> 41 -> 2 -> ... -> 27
duplicate node path: 0 -> 0 -> 41 -> 2 -> 27

The lengths of incorrect paths are exactly incremented by one.

How to write a query to get (in this example) exactly 3 path without duplicate nodes?

trojek
  • 3,078
  • 2
  • 29
  • 52
  • Do you have self loops on `node 0` in the data? – MarcoL Feb 21 '14 at 09:14
  • I don't have, or I don't know about it. Do you know how can I check it? – trojek Feb 21 '14 at 10:34
  • possible duplicate of [All paths between two nodes neo4j - incorrect anwser (from neo4j)](http://stackoverflow.com/questions/21894026/all-paths-between-two-nodes-neo4j-incorrect-anwser-from-neo4j) – jjaderberg Feb 21 '14 at 11:49
  • I have checked it and you was right MarcoCI. I have got self loop on node 0. – trojek Feb 21 '14 at 12:10

1 Answers1

0

Your query is correct and there probably is a problem in the database. I replicated your graph structure: console.neo4j. Run START n=node(*) RETURN n to get the ids of node 27 and 0 and then run your query. It returns exactly 3 results.

To check whether you have loops on node 0 execute:

START n=node(0) MATCH n-[r]-n RETURN r
Kristjan Liiva
  • 9,069
  • 3
  • 25
  • 26
  • I have checked it in console and you are right. Do you know some semiautomatic way of moving data from my local database to console.neo4j.org to test my real database? – trojek Feb 21 '14 at 10:37
  • Sorry, I don't know. I added a way to check for self loops to the answer. – Kristjan Liiva Feb 21 '14 at 11:02
  • You can "dump" your database from neo4j-shell, see http://docs.neo4j.org/chunked/milestone/shell-commands.html#_dumping_the_database_or_a_cypher_result_to_cypher_statements – jjaderberg Feb 21 '14 at 11:51
  • I had self loop on node 0. I had removed it and everything is OK. Thanks you for helping. I cannot vote up your answer because I don't have got 15 reputation points. – trojek Feb 21 '14 at 12:12
  • Since you asked the question and the answer solved it for you then you can mark it as accepted. – Kristjan Liiva Feb 21 '14 at 12:24