2
votes

It is easy to identify nodes with a certain number of incoming or outgoing relationships, but I want to identify connection redundancies so I want to get a set of all nodes with more than one relationship towards each other.

Pseudo code which unfortunately does not return any results:

MATCH (n1)-[r]-(n2)
with distinct n1,r,n2, count(r) as sstcount
where sstcount > 1
RETURN n1,r,n2
2

2 Answers

2
votes

I think I found a solution, the queries need to be correctly linked. Any "nicer solutions" highly appreciated.

MATCH (n1)-[r]-(n2)
WITH distinct n1,n2, count(r) as sstcount
MATCH (n1)-[r]-(n2)
where sstcount>1
return n1,r,n2
0
votes

Try this one instead:

MATCH (n1)-[r]-(n2)
WHERE id(n1) < id(n2) // so we avoid matching to the same nodes in swapped order
WITH n1,n2, count(r) as sstcount
WHERE sstcount > 1
RETURN n1, n2