1

我有以下 图表布局

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

  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::X节点相关的所有节点。u::1

因为u::4u::3没有链接,我希望遍历忽略该连接并且不返回与u::3. 所以不要返回u::4, u::3, u::2, u::5,它应该只返回u::4

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

4

1 回答 1

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
于 2017-07-02T13:50:52.077 回答