Dgraph:递归可以进行深度图遍历吗?

Dgraph: Deep graph traversal possible with recurse?

关于 Dgraph 在图遍历方面的功能,我有几个问题。

假设我们有一个由 post 类型的节点组成的数据集。每个 post 可以有 n 个 post 回复这个 post。这棵树的深度没有限制。

Dgraph 是否可以搜索从一个起始节点开始的所有叶节点和 return 满足特定条件的所有叶节点?

是否可以设置深度限制以不以庞大的数据集结束?

是否也可以找到满足某个条件的所有父节点的子节点?

最后:Dgraph 中的边是有向的吗?我可以将其包含在查询中吗?

这里是 Dgraph 的作者。

Is it possible with Dgraph to search trough all leaf nodes starting from one starting node and return all leafs that fulfill a certain condition?

是的。您可以使用递归指令 (https://docs.dgraph.io/query-language/#recurse-query).

Is it possible to set a depth limit to not end up with a gigantic dataset?

是的。递归支持最大深度。

Is it also possible to find the children of all parent nodes that fulfill a certain condition?

是的。您可以遍历一条边,并在其上放置一个过滤器。 https://docs.dgraph.io/query-language/#applying-filters

And finally: Are edges in Dgraph directed? And can I include that in the query?

dgraph 中的边是有向的。但是,Dgraph 还支持 "reverse" 索引,可用于自动生成反方向的边。然后,您可以通过在谓词名称前添加波浪号 (~) 来遍历这些反向边。

https://docs.dgraph.io/query-language/#reverse-edges