Using Cypher one could count number of relationships in the following manner
Which will report the number of incoming/outgoing relationships for the
Actor named Sylvester Stallone.
bin/neo4j-shell and running a profile on the query will produce the following output
The Cypher can be rewritten to
And to which the profile is:
From the profile above you will see a reference to
GetDegree(n,None,BOTH) which occurs as a result of the usage of
Because of this we do not actually perform a traversal of relationships from
(n) but rather consult the degree value stored with the given node.
In the above
GetDegree() expression, the 2nd parameter refers to the relationship name, and the 3rd parameter refers to the direction of the relationship.
For example the Cypher of
would result in the following profile:
and thus a