I'm working on a query that should return a path and also exclude some nodes.
This is the query:
MATCH (excluded:Client) WHERE excluded.code IN ["TEST01"] WITH collect(excluded) AS excludedC MATCH path=(b:BaseHierarchy)-->(n:Client:Group)-[:PARENT_OF*]->(c:Client) WHERE n.code = 'EMIRG' WITH excludedC, path, b, collect(c) as clients, n, collect(path) as paths WHERE NONE (c in clients where c in excludedC) WITH b, nodes(path) as nodes, relationships(path) as relationships RETURN b, apoc.coll.toSet(apoc.coll.flatten(collect(relationships))) as relationships, apoc.coll.toSet(apoc.coll.flatten(collect(nodes))) as nodes;
Here you can see an example graph:
My query should return only the circled nodes
But it is returning the whole graph because of the variable length operator I think?
I've tried a couple of different things like filtering the nodes list but it will still return the CP1 and I don't want it to be returned because it is under the excluded node (TEST01). Does anyone know how would I go about this? Any help is appreciated