Cypher:有可能找到跟我朋友一起的令人毛骨悚然的人吗?

时间:2013-02-04 13:56:41

标签: neo4j cypher

假设我已将我自己的Twitter图形下载到Neo4J中。我想找到那些跟随我的朋友的人,他们的数量应该超出预期。更具体地说,我想找到跟随我关注的人的人,但我希望对结果进行排序,以便跟随我朋友数量最多的人排序。可能在Cypher?

1 个答案:

答案 0 :(得分:6)

这是一个控制台示例:

http://console.neo4j.org/r/p36cgj

create (me {n:"a"}), (fo1 {n:"fo1"}), (fo2 {n:"fo2"}), (fo3 {n:"fo3"}), (fr1 {n:"fr1"}),
(fr2 {n:"fr2"}), (fr3 {n:"fr3"}),
fo1-[:follows]->me, fo2-[:follows]->me, fo3-[:follows]->me, me-[:follows]->fr1, 
me-[:follows]->fr2, me-[:follows]->fr3, fo1-[:follows]->fr1, fo2-[:follows]->fr2, 
fo1-[:follows]->fr2, fo1-[:follows]->fr3;


start me=node:node_auto_index(n="me") 
match me-[:follows]->friends<-[:follows]-follower-[:follows]->me 
return follower, count(friends) as creepinessFactor, length(me-[:follows]->()) as countIFollow 
order by creepinessFactor desc;

我很想听听结果,顺便说一下。 :P

您也可以投放where之类的内容:

where not(me-[:follows]->follower)

避免在您的圈子中吸引朋友。

相关问题