我有以下图表 graph layout
如您所见,该图表具有以下关系:
(u::4)-[ADDED_RESOURCE]->(:resource)<-[ADDED_RESOURCE]-(u::3) \\ u::4, u::3 are the ids of the nodes
。
(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::X
相关的所有u::1
个节点。
由于u::4
和u::3
取消关联,我希望遍历忽略该连接,而不返回与u::3
相关的子图。因此,它不应返回u::4, u::3, u::2, u::5
,而应仅返回u::4
。
有没有办法告诉APOC在遍历时忽略它们之间有某种关系的节点?
答案 0 :(得分:2)
我不认为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