我在链中有节点,如下所示:
(a)<-[:rel]-(b)<-[:rel]-(c) ... (x)
Run Code Online (Sandbox Code Playgroud)
(a)是否有一种快速方法来计算和之间的节点(或关系)数量(x),即使它们之间有数千个节点?到目前为止,p=(a)<-[:rel*]-(x)进展“缓慢”。
注意:我不需要知道之间的节点的任何信息,我只想找到距离。
使用最短路径方法:
MATCH (martin:Person { name:"Martin Sheen" }),(oliver:Person { name:"Oliver Stone" }),
p = shortestPath((martin)-[*..15]-(oliver))
RETURN length(p)
Run Code Online (Sandbox Code Playgroud)
https://neo4j.com/docs/developer-manual/current/cypher/#query-shortest-path
| 归档时间: |
|
| 查看次数: |
5411 次 |
| 最近记录: |