Your browser does not support script
Home Search Disclaimer Login/Register
Updated : 21/9/2014

Family Tree Tools

Required Tools

The database structure in which the family information resides enables the creation of both the Pedigree and Family Tree view but some additional tools are required to complete the picture. In particular a tool is needed to calculate the relationship between any two individuals. Whilst the Relationship page describes the methodology behind the calculation of relationship this methodology need to be coded for incorporation into the web display.

Get Ancestors

The first required tool is a function to determine the nearest common ancestor of two individuals.

This is achieved for each individual as follows:

  1. Create a two dimension array to record the generation (or Level) and a CSV string of the database identities of all the relatives of the individual at that level.
  2. Starting at generation (or level) '0' query the database and add the individual id and the spouse id if there is one to the array.
  3. For each subsequent level increase the level number and re-query the database to add the id's of the parents of all all individuals from the previous level.
  4. Repeat the above until there are no more parents in the database.

This procedure will produce two arrays, one for each individual, containing the CSV id's of all ancestors of the individual arranged by generation.

The next srep is to identify the nearest ancestor common to both individuals

Identify Common Ancestor

Starting with the arrays of ancestors (arr1 and arr2) the ancestors are compared generation by generation to identify a common ancestors and the generation relative to each individual at which the common ancestor exists. The methodology used for this search is shown in the following pseudo-code:-

        Anc = -1
        'loop through all generations of individual 2
        For i=0 to Ubound(arr2,1)
            'Convert CSV values to an array
            arrtmp = Split(arr2(i,1),",")
            'loop through each relative of individual 2
            For j=0 to Ubound(arrtmp)
                'loop through all generations of individual 1
                For k=0 to Ubound(arr1,1)
                    'check if a relative of individual 2 is also a relative of individual 1
                    if instr(("," & arr1(k,1) & ",") , ("," & arrtmp(j) & ",")) then
                        lv1_1 = k   'generation level of common ancestor to individual 1
                        lvl_2 = i   'generation level of common ancestor to individual 2
                        Anc = Cint(arrtmp(j))   'the id of the common ancestor
                        Exit For
                    End if
                if Anc<>-1 then Exit For ' the common ancestor has been found
            if Anc<>-1 then Exit For ' the common ancestor has been found

The output of the above code is the identity of the common ancestor and the generation of that ancestor relative to each individual. The next step is to use these values to identify the relationship between the individuals


The relationship information in the table given on the Relationship page is represented by a multi dimensional array. Normally a two-dimensional array would be sufficient but I elected to use a three dimension array to allow for gender specific relationships. To cover the extent of my family tree an array(12,12,2) is needed. This is 507 fields that have to be initialised. I found the easiest way to initialise a three dimensional array was to save the data in large string using three different value seperators ie (,) for individual values of the third dimension, (;) to seperate the groups of the second dimension and finally (|) to seperate groups of the first dimension. For example and array(2,2,2) would be defined in a string and parsed into an array using the Split function as shown :-

    Dim strValues,arr1,arr2,arr3,i,j,k,arrValues
    strValues = "one,two,three;         four,five,six;              seven,eight,nine|"&_
                "ten,eleven,twelve;     thirteen,fourteen,fifteen;  sixteen,seventeen,eighteen|"&_
                "twenty,thirty,forty;   fifty,sixty,seventy;        eighty,ninety,hundred"
    For i = 0 to ubound(arr1)
       For j=0 to ubound(arr2)
          For k = 0 to ubound(arr3)

Note the use of &_ to contine the line so that the formatting can be used to keep track of the elements. The additional spaces introduced by the formatting layout are removed by the Trim function. Also note that an Array(2,2,2) has 27 elements 3 in each dimension since the array dimension base is 0.

With all the possible relationship descriptions in an array the results of the common ancester search can be used to find the relationship description by accessing the element arrValues(lvl_1,lvl_2,gender) where gender = 0:1:2 the gender of the relative 0=unknown or don't care, 1=male and 2=female.

336 Page Hits