Returning only simple paths in Neo4j Cypher query

前端 未结 3 1137

Given a query like the following:

START n = node(123)
MATCH p = n-[r:LIKES*..3]->x
RETURN p;

The result paths that I get with the query

3条回答
  •  被撕碎了的回忆
    2020-11-29 06:11

    In 2.3.0, use the following:

    MATCH path = (start {id:2})<-[*1..]-(end {id:3}) 
    WHERE ALL(n in nodes(path) where 
              1 = size(filter(m in nodes(path) where m=n))) 
    RETURN start, LENGTH(path) AS length, EXTRACT(p in NODES(path) | p.id), end
    ORDER BY length
    

提交回复
热议问题