Limiting the amount of edges specifically

cypher
(Werner) #1

Good day,

I would like to know if there is a easy way to limit the total number of out going nodes from another node (hope that makes sense)

MATCH (a:Instance) WITH a LIMIT 10 MATCH (a)-[r]-(b) WHERE b.count <> 0 AND b.count IS NOT NULL WITH a,r,b ORDER BY b.count DESC LIMIT 15 RETURN a,b,r;

At the moment I am limiting the total number of b to 15 , but I want to limit it to 5 per a. If that makes sense.

In other words :
I can limit the total number of b ,but I can not limit them specifically per a.
LIMIT b top 20 but not LIMIT b 5 per a.

MATCH (a:Instance)
WITH a LIMIT 10
MATCH (a)-[r]-(b)
WHERE b.count <> 0 AND b.count IS NOT NULL
WITH a,r,b ORDER BY b.count DESC LIMIT 15
RETURN a,b,r;

0 Likes