Recursively query simpler tree-like structures with Gremlin

ぃ、小莉子 提交于 2019-12-02 11:53:11

The by() modulator can take more than just a property key value as an argument. You can also pass in an anonymous traversal which would thus allow:

g.V().hasLabel('RootTopic').
  repeat(out()).times(2).
    emit().
  tree()
    by(values('name','k1','k2').fold())

or you might use project() if you had more complex output:

g.V().hasLabel('RootTopic').
  repeat(out()).times(2).
    emit().
  tree()
    by(project('name','k1','degree').
         by('name').
         by('k1').
         by(both().count())

The main point to take away here is that with an anonymous traversal you can develop just about any output you would like.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!