I have a Neo4j graph where each node is a person. Each person has two properties: Name and City. And the relationships are: friend_of and love.
I'm trying to get the nodes that have friends ONLY in their same city (A live in Paris, B in Paris, C in Madrid, D in Madrid, A-[friend_of]->B, B-[friend_of]->C a A-[friend_of]->C, D-[friend_of]->C I only need to get A and D because their friends live in their same city and only there) and order them by City first and then by Name.
I have tried the following:
MATCH (n)-[r:FRIEND_OF]-(n1) WHERE (n.City = n1.City) RETURN n,n1 ORDER BY n.City, n.Name
That gives me the nodes wanted, but some of them are wrong too (they have friends in other cities).
Thank you!