Neo4j Cypher-从结果中删除子图
我有下面的图表 如您所见,该图显示了以下关系:Neo4j Cypher-从结果中删除子图,neo4j,cypher,neo4j-apoc,Neo4j,Cypher,Neo4j Apoc,我有下面的图表 如您所见,该图显示了以下关系: (u::4)-[添加的资源]->(:资源)(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 no
(u::4)-[添加的资源]->(:资源)(u::3)
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::4
和u::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
谢谢,但是如果我想同时维护
取消链接
和添加的资源
链接,我会遇到问题。无论取消链接
关系如何,它仍将返回所有已连接的用户。