Neo4j source path excludes node with specific label

I had a problem retrieving a path in neo4j, excluding a specific label.

For example, I have

               -->(h)-->(j)
              /
(a)-->(b)-->(c)-->(d)-->(i)
        \           
         -->(f)-->(g)

with hnode has a label Deleted.

I have a request

MATCH path = (n)-[*]->(child) where id(n)={id of node a} and NOT child:Deleted RETURN path

then I want this request to return the full path, but exclude the subtree node h, since node his Deleted.

the return tree should be like

(a)-->(b)-->(c)-->(d)-->(i)
        \           
         -->(f)-->(g)

But the request seems to be inoperative.

Can anyone help me on this.

thank

+4
source share
3 answers

What worked for me is understanding the list of nodes in the path:

MATCH path = ()-[*]->()
WHERE NONE(n IN nodes(path) WHERE n:Deleted)
RETURN path
+1
source

APOC Procedures , .

match (a)
where id(a) = {id of node a}
call apoc.path.expandConfig(a, {labelFilter:'-Deleted'}) yield path
return path
+1

You need to check both nodes for the label:

match p=((a)-[r:NEXT]->(b))
where  not (a:Deleted or b:Deleted)
return p

here is another example:

match (a)-[r:NEXT]->(b) 
where  not (("Deleted" in labels(a)) or
            ("Deleted" in labels(b))) 
return a, r, b
-1
source

All Articles