Cypher:有可能在我的朋友之后找到令人毛骨悚然的人吗? [英] Cypher: Is it possible to find creepy people following my friends?

查看:90
本文介绍了Cypher:有可能在我的朋友之后找到令人毛骨悚然的人吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我已将自己的本地Twitter图拉入Neo4J.我想找到跟随我的朋友人数更多的人,这应该是我们所期望的.更具体地说,我想找到跟随我所关注的人的人,但是我希望对结果进行排序,以使跟随我最多朋友的人被首先排序.可以在Cypher中吗?

Let's say I've pulled down the Twitter graph local to myself into Neo4J. I want to find people who follow my friends in number larger that should be expected. More specifically, I want to find people who follow the people I follow, but I want the results to be sorted so that the person following the highest number of my friends is sorted first. Possible in 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;

我很好奇听到结果,顺便说一句. :P

I'm curious to hear the results, btw. :P

您还可以添加where,例如:

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

为避免在圈子中结识朋友.

To avoid getting friends within your circle.

这篇关于Cypher:有可能在我的朋友之后找到令人毛骨悚然的人吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆