I'm still at my earlier stages with graphs and gremlin.
Is it possible to randomly select graph vertices in Gremlin?
Consider the following pipeline that gets the cars owned by a user's friend:
u.out('Friend')[0..9].out('Drives').map()
But this code is only executed against the first 10 friends every time. How can I make the selection random efficiently?
Thank you for your time :)
In Gremlin 2.x you could use random step as in:
g.v(1).out.random()
or in 3.x random has become coin:
as in:
g.V(1).out.coin()
in 3.x, you might also look at sample and order(shuffle) steps in 3.x.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With