简体   繁体   English

ArangoDB 获取树根节点

[英]ArangoDB Get Tree Root Nodes

I'm storing basic hierarchical game trees in ArangoDB as graphs.我在 ArangoDB 中将基本的分层游戏树存储为图形。 Each game tree has a start node, and each node (including the start node) 2-5 edges (actions).每棵博弈树都有一个起始节点,每个节点(包括起始节点)有2-5条边(动作)。 I have 2 collections, nodes for vertices and actions for edges.我有 2 个 collections,顶点节点和边动作。

I'm using the Node JS SDK and I'm trying to find the best way to query all start nodes?我正在使用 Node JS SDK 并且试图找到查询所有起始节点的最佳方法? Should I add an isRoot property to nodes and query the nodes collection using that?我应该向节点添加 isRoot 属性并使用它查询节点集合吗? Or should I query all nodes doing a filter using the actions collection to find nodes without inbound edges?或者我应该使用操作集合查询所有执行过滤器的节点以查找没有入站边缘的节点? Or a separate collection of start nodes?还是单独的起始节点集合?

Traversal or aggregation-based approaches to find root nodes will not be very efficient.查找根节点的遍历或基于聚合的方法不会非常有效。 The fastest option is probably to add an isRoot attribute that you can query for and potentially index.最快的选择可能是添加一个isRoot属性,您可以查询并可能索引该属性。

You could also create an extra vertex that has an outgoing edge to every root node so that you can do a 1-hop traversal from this node to all root nodes.您还可以创建一个额外的顶点,该顶点具有到每个根节点的出边,以便您可以从该节点到所有根节点进行 1 跳遍历。 But that could get in the way if you want to traverse in the opposite direction and that node would be a supernode that one typically tries to avoid.但是,如果您想沿相反方向遍历,并且该节点将是一个通常试图避免的超级节点,这可能会妨碍您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM