密码 - 从结果中删除子图



>我有下图 图形布局

如您所见,下图显示了以下关系:

  1. (u::4)-[ADDED_RESOURCE]->(:resource)<-[ADDED_RESOURCE]-(u::3) \ u::4, u::3 are the ids of the nodes.

  2. (u::4)-[UNLINK]->(u::3)

我正在使用 APOC 遍历图形,如下所示:

MATCH (u:user {id:"u::1"}
CALL apoc.path.expandConfig(u,{minLevel:1,maxLevel:6,bfs:true,uniqueness:"NODE_PATH",labelFilter:">resource"}) YIELD path
with u, path, filter(n in nodes(path) where n:resource) as resources
unwind resources as resource
MATCH (rus:user)-[]->(resource)
RETURN distinct rus.id

这将通过其相关资源返回与节点u::1相关的所有u::X节点。

由于u::4u::3是未链接的,我希望遍历忽略该连接,并且不返回与u::3相关的子图。所以它不应该返回u::4, u::3, u::2, u::5,而应该只返回u::4

有没有办法告诉APOC在遍历时忽略它们之间有一定关系的节点?

我不认为apoc.path.expandConfig会允许你忽略关系类型的列表,但它会遵循积极表达的关系类型。 并且它可以选择地解释与<>的顺序。

MATCH (u:user {id:"u::1"}
CALL apoc.path.expandConfig(u
{
minLevel:1,
maxLevel:6,
bfs:true,
uniqueness:"NODE_PATH",
labelFilter:">resource",
// add relationship filter to folow only relationships that are included
relationshipFilter: 'ADDED_RESOURCE|OTHER_TYPE|...'
}) YIELD path
with u, path, filter(n in nodes(path) where n:resource) as resources
UNWIND resources as resource
MATCH (rus:user)-[]->(resource)
RETURN distinct rus.id

最新更新