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 que
More information would be helpful, but in general you can get the degree of a node by doing something like:
MATCH (n)--(other)
WHERE n.id = {id}
RETURN count(other)
If you want to find degrees for many nodes you can leave out the WHERE
or specify a more generic query:
MATCH (n)--(other)
WHERE n.property = {value}
RETURN n, count(other)
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;