The following stack overflow question
How to increase performance of shortest path using Gremlin?
shows how to find the shortest path from a start a single starting vertex with id 687
to an ending vertex with id 1343
and does so efficiently by ensuring no paths are repeated using store
, without
, and aggregate
g.V(687).store('x').repeat(out().where(without('x')).aggregate('x')).until(hasId(1343)).limit(1).path()
I would like to perform the same query with the same level of efficiency, however I need all the shortest paths from multiple starting vertices with the same label all to the same ending vertex, for example it would look something like this (though this doesn't work)
g.V().hasLabel('label').store('x').repeat(out().where(without('x')).aggregate('x')).until(hasId(1343)).limit(1).path()
I have tried multiple constructs with two repeats in the statement, but am not able to get an independent store('x')
for each starting vertex. I am also using AWS Neptune
platform, so it restricts the usage of Gremlin where loops/scripts are not allowed. All gremlin queries must start with g.
and be composed of commands chained together with .
https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-differences.html