Find shortest path between 2 nodes using a node property filter

后端 未结 1 1301
情深已故
情深已故 2021-01-27 08:09

I have a graph database that consists of nodes (bus stations) with a property called “is_in_operation” which is set to “true” if the bus station is operational; otherwise it is

相关标签:
1条回答
  • 2021-01-27 08:49

    The problem is that shortestPath can't take into account the where clause, so you're matching the shortest path, and then filtering it out with your where.

    How about this one--it might not be as efficient as shortestPath, but it should return a result, if one exists:

    START d=node(1), e=node(5) 
    MATCH p = d-[*..15]->e
    where all (x in nodes(p) where x.is_in_operation='true')
    RETURN p
    order by len(p)
    limit 1;
    
    0 讨论(0)
提交回复
热议问题