我尝试了以下查询@ http://goo.gl/Ou2GZG
START s=node(1), t=node(4)
MATCH p=s-[*]-pt--t
WHERE SINGLE (n1 IN nodes(p)
WHERE id(n1)=id(t))
WITH DISTINCT pt AS pts, t
MATCH p=t-[*]-pfn
WHERE NONE (n IN nodes(p)
WHERE id(n)=3 OR id(n)=7)
RETURN DISTINCT pfn AS pf
但我不想在倒数第二行硬编码3和7,其中3和7是(pts)中包含的节点。我尝试了以下但是我得到了“Unclosed parenthesis”错误
START s=node(1), t=node(4)
MATCH p=s-[*]-pt--t
WHERE SINGLE (n1 IN nodes(p)
WHERE id(n1)=id(t))
WITH DISTINCT pt AS pts, t
MATCH p=t-[*]-pfn FOREACH(pt in pts :
WHERE NONE (n IN nodes(p)
WHERE id(n)=id(pt)))
RETURN DISTINCT pfn AS pf
答案 0 :(得分:1)
我认为你可以使用ALL谓词来确保路径p中的每个节点n都不存在pt中与节点n具有相同id的节点,
START s=node(1), t=node(4)
MATCH p=s-[*]-pt--t
WHERE SINGLE (n1 IN nodes(p)
WHERE id(n1)=id(t))
WITH DISTINCT collect(id(pt)) AS pts, t
MATCH p=t-[*]-pfn
WHERE ALL (n IN nodes(p)
WHERE NONE (pt IN pts
WHERE id(n)= pt))
RETURN DISTINCT pfn AS pf