How to detect all the loops in Neo4j?
If we have two nodes A and B :
A including: A.ID, A.Year, A.Name, and B including: B.ID, B.Year, B.Name ,
That A.Name and B.Name are related to each other based on A.ID = B.ID, How we can detect all the loops among the nodes that shows A.Name related to B.Name and B.Name related to A.Name (directly or with some nodes in between)?
There is https://neo4j.com/labs/apoc/4.4/overview/apoc.nodes/apoc.nodes.cycles/ but it's based on explicit loops, formed by relationships between nodes, not implicit equality associations like A.ID
and B.ID
in your example.
The first step would be extract the ID properties of your nodes to a property of a relationship created between each matching pair.
Then you could call apoc.nodes.cycles
.