I have a graph with 4 levels. While filtering using MATCH
, how can i get the "degree" of a node? I am always getting a "degree" of 1.
Here is my query:
MATCH (k)-[r*]->(n:ABC)
WITH k,r,n,count(k) as degree
WHERE k.Value='30 ' AND degree > 1
RETURN n,r,k,degree;
You are getting count of 1 because you aggregated over all 3, start-node, end-node, and all relationships in the path.
This is the most efficient way.
MATCH (k)
WITH k, size((k)-[:TYPE]->()) as degree
WHERE k.Value='30 ' AND degree > 1
MATCH (k)-[r:TYPE]->(n:ABC)
RETURN n,r,k,degree;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With