Open jazzido opened 10 years ago
Just for the record:
-- transitive closure of the edges defined in `grano_relation`
WITH RECURSIVE search_graph(source_id, target_id, id, depth, path, cycle)
AS (
SELECT e.source_id, e.target_id, e.id, 1,
ARRAY[e.id],
false
FROM grano_relation e
UNION ALL
SELECT e.source_id, e.target_id, e.id, sg.depth + 1,
path || e.id,
e.id = ANY(path)
FROM grano_relation e, search_graph sg
WHERE e.source_id = sg.target_id AND NOT cycle
)
SELECT * FROM search_graph;
Collecting stuff:
I'm really interested in exploring the MQL approach and have started an extension to that end here:
Gremlin looks like a great resource to draw inspiration from.
More relevant links:
Idea: implement a subset of Gremlin. Doesn't look that hard.