Reputation: 809
I am trying to use the following script to get the shortest path:
g.V.filter{it.name == 'station1'}.out.dedup().loop(2){it.object.name != "station5" & it.loops < 30}.path{it.name}
If there are more than 1 shortest path in the graph, how do I modify the script to list all of them?
Upvotes: 0
Views: 1110
Reputation: 46226
I updated GremlinDocs Shortest Path Recipe to perhaps better address the topic:
http://gremlindocs.com/#recipes/shortest-path
The example basically culminates in doing a path distribution:
gremlin> g.v(1).out.loop(1){it.object.id!="5" && it.loops< 6 }.path{it.name}.groupBy{it.size()}{it}.cap.next()
==>2=[[marko, ripple]]
==>3=[[marko, josh, ripple], [marko, lop, ripple]]
==>4=[[marko, josh, lop, ripple]]
Note that two paths of length 3 are shown.
Upvotes: 4