![](/img/trans.png)
[英]Neo4j Cypher how to include another relationship node of parent in APOC neo4j cypher query
[英]How to find the most connected node of particular relationship type in neo4j using cypher query?
有人可以幫助我使用密碼查詢在neo4j中找到特定關系類型中連接最緊密的節點。
假設我有
Node1 Node2關系
A B跟着
C跟隨
B D跟着
這里節點D是連接最緊密的節點。特定關系類型為“跟隨”。那么如何使用密碼查詢找到該節點?
提前致謝
(編輯):我找到了答案tnx Martin Preusse
MATCH (n)<-[r:FOLLOWS]-() RETURN n, count(r) AS num ORDER BY num desc
如果關系的方向很重要,請嘗試以下操作(只會返回A
和B
):
MATCH (n)-[r:follows]->()
RETURN n, count(r) AS num
ORDER BY num
如果不需要方向,也可以這樣(即節點D
也將被返回):
MATCH (n)-[r:follows]-()
RETURN n, count(DISTINCT r) AS num
ORDER BY num
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.