As the title says, I have a graph of nodes which are interconnected with a relationship N. I now want to find all pairs of nodes which are further than 20 hops away from each other.
A naive approach with the following cypher query is far too slow:
MATCH (n:CELL)
WITH n
MATCH (k:CELL)
WHERE NOT (n)-[:N*1..20]->(k)
RETURN n, k
I could create a second relationship K with a "distance" property and then match that, but to do so for every Node doesn't exactly scale well (I've got 18k nodes, so I would need more than 160 million new relationships).
Is there any other way to solve this in neo4j?