Frage

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

War es hilfreich?

Lösung

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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top