2016-06-16 104 views

回答

2

當然,這是可能的:

MATCH (n6:Node {name:"n6"}) 
MATCH (n1:Node {name:"n1"})-[r:p]->() 
WITH n1, n6, collect(r) as pRels 
RETURN ALL(x IN pRels WHERE shortestPath((n1)-[*]-(n6))) 

這將返回true或false

1
// End node 
MATCH (n6 {name:"n6"}) 
// Start node and neighbors 
MATCH (n1 {name:"n1"})-[:p]-(n) 
// Shortest paths through the neighbor to the end node, 
OPTIONAL MATCH p = shortestPath((n)-[*]-(n6)) 
    // which does not pass through the starting node 
    WHERE NOT n1 IN nodes(p) 
WITH 
    size(collect(distinct n)) as neighborsCount, 
    count(p) as neighborsWithPathCount 
RETURN neighborsCount = neighborsWithPathCount AND 
     neighborsWithPathCount > 0