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