I want to find the difference between the number of all the outgoing edges and the number of all incoming edges to the same node. Nodes are cities and relationships are transfers between them.
I've tried to do this:
MATCH ()-[i:TRANSFERS]->(n:City {name:"London"}),(n:City {name:"London"})-[o:TRANSFERS]->()
RETURN distinct n.name, count(i) AS incoming, count(o) as outgoing, count(o)-count(i) AS difference
ORDER BY outgoing - incoming DESC
and this:
MATCH ()-[i:TRANSFERS]->(n:City {name:"London"})
OPTIONAL MATCH (n:City {name:"London"})-[o:TRANSFERS]->()
RETURN distinct n.name, count(i) AS incoming, count(o) as outgoing, count(o)-count(i) AS difference
ORDER BY outgoing - incoming DESC
but they seem not working. Any idea?