drdot
drdot

Reputation: 3347

cypher find path without a node type

Say I have the following graph

(:A) -> (:B) -> (:C) -> (:D)
  \                ^
   \               |
     -> (:X) -> (:Y) 

Now from A to D, there are two paths

(:A) -> (:B) -> (:C) -> (:D)

and

(:A) -> (:X) -> (:Y) -> (:C) -> (:D)

I can use the query below to return the two path

MATCH p1 = ((:A)-[*]-(:Z))
return p1

But say I only want to see path that does not contain node type X. What query can I use?

Upvotes: 0

Views: 196

Answers (1)

Graphileon
Graphileon

Reputation: 5385

You can use the NONE() predicate function (see https://neo4j.com/docs/cypher-manual/current/functions/predicate/#functions-none)

MATCH p1 = ...
WHERE NONE(node IN nodes(p1) WHERE node:X)

Upvotes: 2

Related Questions