I am trying to detect cycles in a graph created on postgreSQl and Apache AGE using WITH RECURSIVE method. Can someone guide me why my cypher query would not be able to detect cycles? I have using this reference. Below is my trying code:
WITH RECURSIVE dependency_path AS (
SELECT module_id, dependency_id, ARRAY[module_id] AS path
FROM dependencies
UNION ALL
SELECT dp.module_id, d.dependency_id, path || dp.module_id
FROM dependency_path dp, dependencies d
WHERE dp.dependency_id = d.module_id
AND NOT (dp.path @> ARRAY[d.dependency_id])
)
SELECT path || dependency_id AS cycle
FROM dependency_path
WHERE module_id = dependency_id
AND path @> ARRAY[dependency_id];