看起来它返回结构,但值不存在......
g = TinkerGraphFactory.createTinkerGraph()
root = g.v(1)
def tree
def results = []
tree = { vertices ->
vertices.each() {
children = it.out().toList()
if (children)
results << tree(children)
}
results.toList()
}
println tree(root)
以下是结果......
$ ./gremlin.sh -e treeTest.groovy
[[], [[]]]
注意:我通常使用Python而不是Groovy,所以我可能错过了一些明显的东西。
答案 0 :(得分:0)
tree = { vertices ->
def results = []
vertices.each() {
results << it
children = it."$direction"().toList()
if (children) {
child_tree = tree(children)
results << child_tree
}
}
results
}