答案 0 :(得分: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 :(得分: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