我仍然处于早期阶段的图形和gremlin.
是否可以在Gremlin中随机选择图形顶点?
考虑以下用于获取用户朋友拥有的汽车的管道:
u.out('Friend')[0..9].out('Drives').map()
但是这个代码每次只针对前10个朋友执行.如何有效地随机选择?
感谢您的时间 :)
在Gremlin 2.x中,您可以使用随机步骤,如下所示:
g.v(1).out.random()
Run Code Online (Sandbox Code Playgroud)
或者在3.x random中成为硬币:
如:
g.V(1).out.coin()
Run Code Online (Sandbox Code Playgroud)
在3.x中,您还可以查看3.x中的示例和顺序(shuffle)步骤.