问题
I want to get all path between two nodes with the relation "->" between them. I ask my DB using query (Cypher) like that:
START a=node(27), b=node(0) MATCH p=b<-[*]-a RETURN p
In Neo4j visualization I get this:
Cypher query visualization
I want to get list of 3 path:
- 27 -> 81 -> .... -> 0
- 27 -> 67 -> .... -> 0
- 27 -> 24 -> .... -> 0
but in the result I have got 6 paths (instead of 3). I want to figure out why.
回答1:
This happens because the query includes the 0 length paths starting from 'a'. If you look at the file you provided, the last three results are the same as the first three ones, except for the duplication of Node[0] at the beginning of the path.
回答2:
Your (OwlThing)
has a [:subClassOf]
relationship to itself. It doesn't show in the visualisation, but that's what
Node[0]{name:"owl:Thing"},:subClassOf[35]{},Node[0]{name:"owl:Thing"}
in your results means. For every path from that ends with (41)-[43]->(0)
there is also a (41)-[43]->(0)-[35]->(0)
which means your results are doubled.
来源:https://stackoverflow.com/questions/21894026/all-paths-between-two-nodes-neo4j-incorrect-answer-from-neo4j