家谱的数据结构
我想知道哪种数据结构最适合存储一个人的家谱,有配偶关系、子女关系和父母关系。我还想知道一个人是否与另一个人有血缘关系。
如果能找到 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
图表最适合这种情况,我建议您使用
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 useBoost
.是家庭作业吗?
即使它被称为“树”,这也是一个糟糕的结构:想象一下两个兄弟娶了两个姐妹。
一般的图结构将是最好的(树是图的特定形式)。边缘将承载关系。然后,您可以仅在代表血缘关系的边缘上运行路径查找算法(如老式的 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.