Calculating In Degree and Out Degree in a single query

769 Views Asked by At

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?

1

There are 1 best solutions below

2
On BEST ANSWER

Can you try this query :

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

Cheers.