简体   繁体   中英

duplicated one node in path - cypher (query all path between two nodes)

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM