-1

我尝试了以下查询@ 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) 中包含的节点。我尝试了以下操作,但出现“未闭合的括号”错误

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
4

1 回答 1

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
于 2013-08-17T13:17:57.203 回答