在单个查询中计算度和出度

时间:2017-08-29 06:51:54

标签: neo4j cypher cypher-3.1

我可以使用以下查询" In Degree"成功:

match a=(p:Person)-->(q:Person{Address:'0xa1e4380a3b1f749673e270229993ee55f35663b4'})
RETURN count(a) as In_Degree

我可以使用以下查询" Out Degree"成功:

match a=(p:Person)<--(q:Person{Address:'0xa1e4380a3b1f749673e270229993ee55f35663b4'})
RETURN count(a) as Out_Degree

但是当我同时兼顾并写下如下查询时,Cypher正在给出&#34; Out Degree&#34;的结果。

match a=(p:Person)-->(q:Person{Address:'0xa1e4380a3b1f749673e270229993ee55f35663b4'}),b=(r:Person)<--(s:Person{Address:'0xa1e4380a3b1f749673e270229993ee55f35663b4'})
RETURN count(a) as In_Degree, count(b) as Out_Degree

我在这里遗漏了什么吗?有人可以帮我这个吗?

1 个答案:

答案 0 :(得分:2)

您可以尝试此查询:

MATCH (p:Person{Address:'0xa1e4380a3b1f749673e270229993ee55f35663b4'})
RETURN size((p)<--(:Person)) AS In_Degree, size((p)-->(:Person)) AS Out_Degree

干杯。