如何从 Cypher 中的路径中排除节点?

How to Exclude nodes from Path in Cypher?

我一直在编写一个 Cypher 查询,它可以让我找到所有其代码未包含在给定列表中的节点。我尝试在路径中搜索模式否定、节点否定、排除,但均未成功。

假设我有一个代码列表(即使这个列表有 1 个元素):["1V2ZG"]

我想构建一个 Cypher 查询,return ARNOG 节点的每个子节点不在上面的列表中。

这是起始图:

我想要的图形响应:

我正在使用的查询是 returning 所有节点,这不是我想要的:

MATCH 
(excl:Client)<-[:PARENT_OF*]-(n:Client:Group),
path=(b:BaseHierarchy)-[:INCLUDES]->(n)-[:PARENT_OF*]->(inc:Client) 

WHERE excl.code IN ['1V2ZG']  AND n.code = 'ARNOG' 
WITH b,
nodes(path) as nodes, relationships(path) as relationships 
RETURN b,
apoc.coll.toSet(apoc.coll.flatten(collect(relationships))) as relationships,
apoc.coll.toSet(apoc.coll.flatten(collect(nodes))) as nodes;

怎么样:

MATCH path=(b:BaseHierarchy)-[:INCLUDES]->(n)-[:PARENT_OF*]->(inc:Client) 
WHERE n.code = 'ARNOG' AND 
      NONE(node IN nodes(path) WHERE node.code IN ['1V2ZG'])
WITH b, nodes(path) AS nodes, relationships(path) AS relationships 
RETURN b,
       apoc.coll.toSet(apoc.coll.flatten(collect(relationships))) as relationships,
       apoc.coll.toSet(apoc.coll.flatten(collect(nodes))) as nodes;

?