家谱的数据结构

发布于 2024-12-21 07:26:53 字数 116 浏览 1 评论 0原文

我想知道哪种数据结构最适合存储一个人的家谱,有配偶关系、子女关系和父母关系。我还想知道一个人是否与另一个人有血缘关系。

如果能找到 c++ STL 中的一些数据结构就好了。

只需要想法。

I want to know that which data structure suits best for storing the family tree for a person, there are spousal, child and parental relationships. Also i want to know that if one person is has blood relationship with other.

It would be good i some data structure from c++ STL can be found.

Just ideas are required.

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

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

发布评论

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

评论(2

偏爱自由 2024-12-28 07:26:53

图表最适合这种情况,我建议您使用Boost

请注意,构建家谱可能会很棘手,如此问题所示。

否则,std 不会定义图形数据结构。由于图表显然最适合您的情况,我建议您要么实现自己的版本,要么使用 Boost

A graph would be best suited for this, and I suggest you use Boost.

Note that building a family tree can prove to be tricky, as illustrated by this question.

Otherwise, std doesn't define a graph data structure. And since a graph is obviously best suited for your situation, I suggest you either implement your own version, or use Boost.

不再让梦枯萎 2024-12-28 07:26:53

是家庭作业吗?

即使它被称为“树”,这也是一个糟糕的结构:想象一下两个兄弟娶了两个姐妹。

一般的图结构将是最好的(树是图的特定形式)。边缘将承载关系。然后,您可以仅在代表血缘关系的边缘上运行路径查找算法(如老式的 dijkstra)。

boost::graph 是一个非常好的库。

Is it homework?

Even if it's called “Tree”, It's a bad structure : imagine two brother who marry two sisters.

A general graph structure would be the best (a tree being a specific form of a graph). The edge would carry the relationship. Then you can run a path finding algorithm (like good old dijkstra) only on edges which represent blood relationship.

And boost::graph is a very good library.

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