Counting the number of edges connected to a node with Neo4j is possible using only Cypher and aggregation functions. For instance, the following query counts the number of outgoing relationships from each node:
MATCH (n:Node)-[r:LINKED_TO]->()
RETURN n.name, count(r) as outgoingDegree
ORDER BY outgoingDegree DESC
Running this query on the small graph we studied in the previous section gives us the following result:
╒══════════╤════════════════╕
│"nodeName"│"outgoingDegree"│
╞══════════╪════════════════╡
│...