假设我已将我自己的Twitter图形下载到Neo4J中.我想找到那些跟随我的朋友的人数量应该超出预期.更具体地说,我想找到跟随我关注的人的人,但我希望对结果进行排序,以便跟随我朋友数量最多的人排序.可能在Cypher?
这是一个控制台示例:
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;
Run Code Online (Sandbox Code Playgroud)
我很想听听结果,顺便说一下.:P
你也可以扔一个where
像:
where not(me-[:follows]->follower)
Run Code Online (Sandbox Code Playgroud)
避免在你的圈内吸引朋友.