I want to obtain all wallet nodes except for those in wallet-pairs with only one :SendTo
relationship between them and no :SendTo
relationships to any other wallets. Is this query correct for that purpose?:
MATCH (n:Wallet)
OPTIONAL MATCH (n)-[r1:SendTo]-(n1:Wallet)-[r12:SendTo]-(n2:Wallet)
WHERE n <> n1
WITH n,count(n1) + count(n2) as rels
OPTIONAL MATCH (n3:Wallet)-[r2:SendTo]-(n)-[r22:SendTo]-(n4:Wallet)
WHERE n <> n3
WITH n, rels, count(n3) + count(n4) as rels1
WHERE rels1 > 0 or rels>0
return n
From the test I have done, I would say that it is correct. But I would prefer a second opinion.
AS to how the graph is created: each wallet node is connected to another wallet node or itself via one or more unidirectional :SendTo
relationships. It is possible to have more than one such relationship between the same two wallet nodes.
WITH n, size((n)-[:SendTo]-()) as degree WHERE degree > 1 AND ...
– InverseFalcon