neo4j-相互计数的用户建议 [英] neo4j - user suggestion with mutual count
本文介绍了neo4j-相互计数的用户建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在neo4j中创建了5个节点,如下所示.
I have created 5 nodes in neo4j as follows.
Node 1 {userid:1000, username: A, someOtherProperties...}
Node 2 {userid:2000, username: B, someOtherProperties...}
Node 3 {userid:3000, username: c, someOtherProperties...}
Node 4 {userid:4000, username: D, someOtherProperties...}
Node 5 {userid:5000, username: E, someOtherProperties...}
与节点2和节点2连接的节点1. 3,节点2与节点1、3、4相连
Node 1 connected with Node 2 & 3, and Node 2 connected with node 1, 3, 4
1 -> 2
1 -> 3
2 -> 1
2 -> 3
2 -> 4
3 -> 4
现在,我要为节点1提供用户建议,其中包含未与之连接的那些节点 它具有相互计数的自我.我想要这样的结果.
Now I want user suggestion for node 1 which contain those node which is not connected with it self with mutual count. I want result like this.
node id userid username mutual count
------- ------ -------- -------------
4 4000 D 2 (which is node 2 & 3)
5 5000 E 0
我尝试了密码查询,但是没有成功.
I had tried cypher query, but I didn't get success.
推荐答案
请尝试
START user=node:node_auto_index(name='A'), f=node(*)
MATCH user-[r?:FRIEND*1..2]->(f)
WITH DISTINCT r AS friendRelation,f
RETURN count(friendRelation),f
这将为您提供与其他每个深度为2的节点(朋友的朋友)的朋友关系的数量
Which will give you the number of friend relations to every other node with a depth 2 (friend of a friend)
这篇关于neo4j-相互计数的用户建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文