【发布时间】:2018-09-07 08:57:13
【问题描述】:
我正在尝试收集不同路径长度的节点以及根据路径长度分配变量的目标。不在路径中的节点 = 分离,路径长度 1 = 半,路径长度 > 1 = 梯形。
我有以下密码,但是在返回收集的列表时没有返回任何内容,即使每个部分都可以正常工作。
match (a:Test) where not (a)-[]-() with a, COLLECT(DISTINCT a) as detached
match (a:Test)-[r]-() with a,detached,count(r) as rels where rels = 1
match path = (a)-[]->() with detached, COLLECT(DISTINCT NODES(path)) AS semis
match path = (a)-[:NEIGHBOURING_BUILDING*]-() where length(path) > 1 with detached, semis, COLLECT(DISTINCT NODES(path)) AS terraces
return detached, semis, terraces
我目前正在使用这个测试网络
create (:Test{id:1})
create (:Test{id:2})
create (:Test{id:3})-[:NEIGHBOUR]->(:Test{id:4})
create (:Test{id:5})-[:NEIGHBOUR]->(:Test{id:6})<-[:NEIGHBOUR]-(:Test{id:7})
create (:Test{id:8})-[:NEIGHBOUR]->(:Test{id:9})
create (:Test{id:10})-[:NEIGHBOUR]->(:Test{id:11})<-[:NEIGHBOUR]-(:Test{id:12})
如何将每种路径中的节点收集到一个列表中?
【问题讨论】: