用于后代关系的最佳数据结构是什么?

发布于 2024-07-16 06:14:54 字数 194 浏览 5 评论 0原文

必须有一个标准的数据结构来保存例如狗的饲养信息、植物遗传杂交以及复杂的人际关系。

人们可能认为这将是一个简单的树结构,但每个后代有两个(或更多,对于基因工程)父母的组合,每个父母组有多个不同的后代,父母的多次移动(种马与许多其他马交配),收养等使得这是一个非常分散的结构。

我希望之前有人已经解决过这个问题。 我应该研究哪些资源?

There must be a standard data structure to hold, for instance, dog breeding information, plant genetic crossbreeding, and complex human relationships.

One might think it would be an easy tree structure, but the combination of two (or more, for genetic engineering) parents per offspring, multiple different offspring per parent set, multiple moves of parents (stud horses mate with many other horses), adoption, etc makes this a very fragmented structure.

I expect someone has tackled this before though. Any resources I should look into?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北恋 2024-07-23 06:14:54

我认为你拥有的只是一个简单的关系数据库,其中主要关系是“child_of”,“direct_descendant”等。

当然,这里的特定数据结构是非循环的,你可能想要进行传递查询(后代的后代) ...),标准 SQL 引擎通常不支持。

因此,如果您想在内存中执行此操作,可以使用有向无环图(DAG)。

I think what you have is just a simple relational database, where the main relation is "child_of", "direct_descendant", etc.

Of course, the particular data structure here is acyclic, and you might want to do transitive queries (descendant of descendant of ...), which are not usually supported by standard SQL engines.

So if you want to do it in memory, you could us a directed acyclic graph (DAG).

伪装你 2024-07-23 06:14:54

闻起来像DAG。 如果有向和非循环太有限,您可能需要查看图论数据-结构

使用图来解决抽象问题,顶点代表实体,边代表关系。

Smells like a DAG. If the directed and acyclic is too limiting, you might want to look at the graph theory data-structures.

Using graphs for abstract problems, vertices represent entities and the edges represent the relationship.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文