I am trying to find all shortest paths between 2 given nodes with the following query.
MATCH p = allShortestPaths((a)-[*..3]-(g)) WHERE id(a)=$idA AND id(g)=$idG return p
suppose the query returns 3 paths:
- a->b->c->g
- a->b->d->g
- a->e->f->g
Now, I want to filter out paths that contain a particular node say node 'b' i.e. first 2 paths gets filtered out and should return only a->e->f->g. I modified the above query as below
MATCH p = allShortestPaths((a)-[*..3]-(g)) WHERE id(a)=$idA AND id(g)=$idG AND ANY(n in nodes(p) where id(n) = $idExclude) return p
The modified query works well for the above scenario. However, the query freezes and never returns if all paths get filtered out. Consider that 1st query returns only 2 paths:
- a->b->c->g
- a->b->d->g
The NONE function on these paths should check if the nodes on these 2 paths contain node b and return null/empty/no paths. However, the query just freezes and never returns. Kindly let me know what can be done so that query returns empty. Thanks a lot in advance.