Reputation: 2372
I am not very familiar with Neo4j because I just used it for several days.
But now I want to find path between two nodes
like path : A & D
A -> B -> C -> D
A -> B -> E -> D
A -> C -> E -> D
and using "WHERE NOT" to eliminate Node B
so I will leave path A -> C -> E -> D
is there any way I can do this ?
Here is my Cypher:
MATCH (home { name:'Grove' }),(school { name:'Moulton' }),(Ann {name:'Ann'}),
p = ((home)-[*..4]->(school))
WHERE NOT ((home)-[]->(Ann))
RETURN p
It's not working for me
Upvotes: 5
Views: 1338
Reputation: 39915
You can use the NONE
predicate in the WHERE
clause to filter out paths containing the B
node. See http://console.neo4j.org/?id=hppthl for an example.
The cypher statement looks like this:
MATCH p=(:Person { name:'A' })-[:KNOWS*..4]->(:Person { name:'D' }),
(without:Person { name:'B' })
WHERE NONE (x IN nodes(p) WHERE x=without)
RETURN p
Upvotes: 6