Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

data structure for Family tree

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.

like image 608
Abdul Samad Avatar asked Dec 13 '11 10:12

Abdul Samad


People also ask

Which data structure is used for family tree?

A general graph structure would be the best (a tree being a specific form of a graph). The edge would carry the relationship.

What is a family tree diagram called?

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.


2 Answers

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.

like image 69
Luchian Grigore Avatar answered Sep 29 '22 11:09

Luchian Grigore


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.

like image 36
Tristram Gräbener Avatar answered Sep 29 '22 12:09

Tristram Gräbener