| 1 |
/* |
| 2 |
* @progname tree_density.ll |
| 3 |
* @version 1 |
| 4 |
* @author Jim Eggert ([email protected]) |
| 5 |
* @category |
| 6 |
* @output Text |
| 7 |
* @description |
| 8 |
|
| 9 |
This program calculates the weight of each node in an ancestral tree. |
| 10 |
The weight of a node is given by the number of people in the database |
| 11 |
that are most closely related to that node. The degree of relation is |
| 12 |
measured in hops, where a hop is a step to a parent, spouse, sibling, |
| 13 |
or child. Thus this program allows you to get an idea of where most |
| 14 |
of the research has been done, where large numbers of cousins hook in |
| 15 |
to the database, and where more work may be needed. |
| 16 |
|
| 17 |
The output of the program is a simple ahnentafel with the ahnentafel |
| 18 |
number, node weight, and key and name of the ancestors. |
| 19 |
|
| 20 |
tree_density - a LifeLines program |
| 21 |
by Jim Eggert ([email protected]) |
| 22 |
Version 1, 15 February 1996 |
| 23 |
*/ |
| 24 |
|
| 25 |
global(plist) |
| 26 |
global(mark) |
| 27 |
global(anccounts) |
| 28 |
|
| 29 |
proc include(person,anckey) |
| 30 |
{ |
| 31 |
if (person) { |
| 32 |
set(pkey,key(person)) |
| 33 |
if (not(lookup(mark,pkey))) { |
| 34 |
set(skey,save(pkey)) |
| 35 |
set(sanckey,save(anckey)) |
| 36 |
insert(mark,skey,sanckey) |
| 37 |
set(count,lookup(anccounts,sanckey)) |
| 38 |
insert(anccounts,sanckey,add(count,1)) |
| 39 |
enqueue(plist,skey) |
| 40 |
} |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
proc main () |
| 45 |
{ |
| 46 |
table(mark) |
| 47 |
table(anccounts) |
| 48 |
list(plist) |
| 49 |
list(alist) |
| 50 |
|
| 51 |
getindimsg(from_person, |
| 52 |
"Enter person to compute relation from:") |
| 53 |
set(from_key,save(key(from_person))) |
| 54 |
call include(from_person,from_key) |
| 55 |
|
| 56 |
set(counter,0) |
| 57 |
set(nextcount,0) |
| 58 |
|
| 59 |
while (pkey,dequeue(plist)) { |
| 60 |
incr(counter) |
| 61 |
if (ge(counter,nextcount)) { |
| 62 |
print(d(counter)," ") |
| 63 |
set(nextcount,add(nextcount,100)) |
| 64 |
} |
| 65 |
|
| 66 |
set(person,indi(pkey)) |
| 67 |
set(anckey,save(lookup(mark,pkey))) |
| 68 |
if (not(strcmp(pkey,anckey))) { |
| 69 |
call include(father(person),save(key(father(person)))) |
| 70 |
call include(mother(person),save(key(mother(person)))) |
| 71 |
} |
| 72 |
else { |
| 73 |
call include(father(person),anckey) |
| 74 |
call include(mother(person),anckey) |
| 75 |
} |
| 76 |
children(parents(person),child,cnum) { |
| 77 |
call include(child,anckey) |
| 78 |
} |
| 79 |
families(person,fam,spouse,pnum) { |
| 80 |
call include(spouse,anckey) |
| 81 |
children(fam,child,cnum) { |
| 82 |
call include(child,anckey) |
| 83 |
} |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
"Ahnentafel" col(10) " weight" col(20) "key" col(28) "name" |
| 88 |
enqueue(plist,from_key) |
| 89 |
enqueue(alist,1) |
| 90 |
while (pkey,dequeue(plist)) { |
| 91 |
set(a,dequeue(alist)) |
| 92 |
set(p,indi(pkey)) |
| 93 |
if (f,father(p)) { |
| 94 |
enqueue(plist,save(key(f))) |
| 95 |
enqueue(alist,add(a,a)) |
| 96 |
} |
| 97 |
if (m,mother(p)) { |
| 98 |
enqueue(plist,save(key(m))) |
| 99 |
enqueue(alist,add(a,a,1)) |
| 100 |
} |
| 101 |
d(a) col(10) rjustify(d(lookup(anccounts,pkey)),8) |
| 102 |
col(20) key(p) col(28) name(p) "\n" |
| 103 |
} |
| 104 |
} |