Question

I ve recently started with python and am working on building a Family tree using python. My idea is that the tree should grow in both sides, i.e) both the older generations as well as younger generations can be added to the same tree.

I tried implementing with Binary tree ADT and N-ary tree ADT, but that doesn't work well. Can anyone suggest me an ADT that is best for building that family tree, and guide me how to implement that?

Was it helpful?

Solution 2

After searching a lot, I found that the Graph ADT suits the above problem better. Since a family has relations over a wide span in all directions, using a graph ADT would be conventional.

  • Each node can store details about a person.
  • Node can consist of parent node links, and some functionalities to find relation between two nodes etc..
  • To find relationships, assume the parent nodes as the Parents, and the parent of the parent nodes as grandparents etc..
  • Traverse to the parent node, find if there is any other child nodes, mark them as siblings etc..

The idea is this, I think it will help to solve this problem!

OTHER TIPS

If you look at the app "longlines", the GEDCOM file format (not the XML version) and other family tree software, it creates a unique record per-person and per-family unit then uses the ID of those records to create symbolic references to members of families and children.

If you look at this GEDCOM record, it identifies an INDIvidual with id "I25" who is a child (FAMC) of family id F11 and a spouse (FAMS) in families F6 and F12.

  0 @I25@ INDI
  1 NAME Thomas Trask /Wetmore/ Sr
  1 SEX M
  1 BIRT
    2 DATE 13 March 1866
    2 PLAC St. Mary's Bay, Digby, Nova Scotia
    2 SOUR Social Security application
  1 NATU
    2 NAME Thomas T. Wetmore
    2 DATE 26 October 1888
    2 PLAC Norwich, New London, Connecticut
    2 AGE 22 years
    2 COUR New London County Court of Common Pleas
    2 SOUR court record from National Archives
  1 OCCU Antiques Dealer
  1 DEAT
    2 NAME Thomas Trask Wetmore
    2 DATE 17 February 1947
    2 PLAC New London, New London, Connecticut
    2 AGE 80 years, 11 months, 4 days
    2 CAUS Heart Attack
    2 SOUR New London Death Records
  1 FAMC @F11@
  1 FAMS @F6@
  1 FAMS @F12@

Human relationships are far more complicated than can be represented in a basic tree-like data structure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top