繁体   English   中英

密码-从结果中删除子图

[英]Cypher - remove subgraph from results

我有以下图图布局

如您所见,该图具有以下关系:

  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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM