I have a neo4j graph with nodes that I need to increment a flag on all of the nodes on paths from a start to end node. But I need to increment this flag only ONCE, even if it lies on multiple paths.
I use the following query, but obviously it loops through all of the paths so the flag is incremented more than once:
MATCH paths = (end:Operation)-[DEPENDS_ON*]->(start:Operation )
WHERE id(start) = 304
AND end.final = true
UNWIND [ops IN nodes(paths)] AS op
SET op.flag = op.flag + 1
How can I unwind or collect the distinct nodes on all paths then increment the property?