Reputation: 397
If currently traversal includes [v1, v2, v3],
v1, v2, v3 all have multiple out vertices,
is it possible to use gremlin to return one out vertex for v1, v2, v3?
E.g.,
v1 out: [v4, v5]
v2 out: [v6, v7]
v3 out: [v8, v9]
Hope result can be sth like: [v4, v6, v8]
Upvotes: 1
Views: 155
Reputation: 2856
If you want to choose one of them in an arbitrary way you can use local
and limit
:
g.V().hasLabel('v1', 'v2', 'v3').local(out().limit(1))
if you have some logic to the filter you can do something like this:
g.V().hasLabel('v1', 'v2', 'v3').local(out().order().by('value').limit(1))
example: https://gremlify.com/6r
Upvotes: 1