Neo4J / Cypher需要帮助编写一个查询,该查询显示通过特定数量的路径连接到初始节点的所有结果节点

时间:2012-12-04 23:42:59

标签: neo4j cypher

在Neo4J中,如何编写Cypher查询,显示通过特定路径连接到初始节点的所有节点?

2 个答案:

答案 0 :(得分:1)

路径数或跳数?

start n=node(x)
match path = n-[:TYPE*..3]->end // number of hops *..3 is up to 3 hops
return path
limit 10 // number of paths

答案 1 :(得分:0)

我想也许他正在寻找:

start n=node(x) 
match path = n-[*]->end      // maybe specify a max length and type?
with count(path) as cnt, end // group by end node, get count of paths
where cnt = <numpaths>       // replace <numpaths> with the number of paths you want to match
return end