2

I could use the below query for "In Degree" successfully:

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

I could use the below query for "Out Degree" successfully:

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

But when I club both and write the query as below, then Cypher is giving the result of "Out Degree".

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

Am I missing something here? Could someone help me with this please?

Fabio Lamanna
  • 20,504
  • 24
  • 90
  • 122
user8494391
  • 49
  • 1
  • 5

1 Answers1

3

Can you try this query :

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

Cheers.

logisima
  • 7,340
  • 1
  • 18
  • 31
  • Thanks for the response. I understand that size worked but may I know the limitation of "count" here? Does "count" not applicable for counting the patterns? – user8494391 Aug 29 '17 at 10:56
  • 1
    count is an aggregate function. In your query you are doing two aggregations successively (and in cypher there is no group by, it's done by the order). – logisima Aug 29 '17 at 11:39