简体   繁体   English

路径中心的 Neo4j / Cypher 节点

[英]Neo4j / Cypher node in center of path

I have a linear path in cypher:我在密码中有一条线性路径:

MATCH path = (s)-[:SOMETHING*]->(e)

What I want is the node in the middle of that path.我想要的是该路径中间的节点。 How can I get it?我怎么才能得到它?

Thanks alot for you time!非常感谢您的时间!

You can use nodes(path) to get the list of nodes in the path.您可以使用nodes(path)来获取nodes(path)中的节点列表。 You can use length(path) to get its length, so:您可以使用length(path)来获取其长度,因此:

MATCH path = (s)-[:SOMETHING*]->(e)
RETURN nodes(path)[length(path)/2] as middle

should get you your middle node.应该让你得到你的中间节点。

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

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