用于后代关系的最佳数据结构是什么?
必须有一个标准的数据结构来保存例如狗的饲养信息、植物遗传杂交以及复杂的人际关系。
人们可能认为这将是一个简单的树结构,但每个后代有两个(或更多,对于基因工程)父母的组合,每个父母组有多个不同的后代,父母的多次移动(种马与许多其他马交配),收养等使得这是一个非常分散的结构。
我希望之前有人已经解决过这个问题。 我应该研究哪些资源?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你拥有的只是一个简单的关系数据库,其中主要关系是“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).
闻起来像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.