在TinkerPop中定义了一个树的API但是它没有很好的实现,有很长一段时间没有更新了。使用小精灵遍历时tree步骤允许您从图的一部分来创建一棵树。下面的例子创建了一个树,深度是3.AUS顶点是树的根。树的下一层是所有直接与AUS 相连的顶点。第三层是和前一层的顶点有路径相连的所有的顶点。
TinkerPop defines a Tree API but it is not that well fleshed out and has not been updated in a long
time. The tree step allows you to create a tree from part of a graph using a Gremlin traversal. The
example below creates a tree, of depth 3, where the Austin (AUS) vertex is the root of the tree. The
next level of the tree is all vertices directly connected to AUS. The third level is made up of all the
vertices connected by routes to the vertices in the previous level.

 

返回对我们的变量树的对象将会是org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree类的实例。这个类提供了一系列的方法,可以用进行树相关的处理。

The object returned to our variable tree will be an instance of the
org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree class. That class provides a set of
methods that can be used when working with a Tree.

 

我们会在“把有序二叉树建模成图”这一节中再次看到树API的使用。

We will see the Tree API used again in the "Modelling an ordered binary tree as a graph" section
later on.
posted on 2022-04-25 16:56  bokeyuannicheng0000  阅读(169)  评论(0)    收藏  举报