While analyzing Java code using jQAssistant I'm frequently facing the problem to detect cycles between packages or modules. My current approach is using the following query:
MATCH (m1:Module)-[:DEPENDS_ON]->(m2:Module), cyclePath=shortestPath((m2)-[:DEPENDS_ON*]->(m1)) RETURN m1, nodes(cyclePath) as cycle
The query works well but the result is redundant: A cycle "a,[b,c,a]" is reported redundantly
i.e. "b,[c,a,b]" and "c,[a,b,c]".
It's clear why this happens - each involved module is a starting point for the cycle - but I'm currently looking for an efficient way to reduce this to just one result. Any ideas out there?