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.
A general graph structure would be the best (a tree being a specific form of a graph). The edge would carry the relationship.
A family tree (similar to pedigree chart) is a diagram representing family relationships in a conventional tree structure. A family tree collage is an interesting way of learning about the heritage and history of the family. It can affect inheritance and be an important clue to a person's lineage and ancestors.
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
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With