File: tree_density.ll

package info (click to toggle)
lifelines 3.0.50-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 11,140 kB
  • ctags: 6,517
  • sloc: ansic: 57,468; xml: 8,014; sh: 4,255; makefile: 848; yacc: 601; perl: 170; sed: 16
file content (104 lines) | stat: -rw-r--r-- 3,003 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
 * @progname       tree_density.ll
 * @version        1
 * @author         Jim Eggert (eggertj@atc.ll.mit.edu)
 * @category       
 * @output         Text
 * @description

This program calculates the weight of each node in an ancestral tree.
The weight of a node is given by the number of people in the database
that are most closely related to that node.  The degree of relation is
measured in hops, where a hop is a step to a parent, spouse, sibling,
or child.  Thus this program allows you to get an idea of where most
of the research has been done, where large numbers of cousins hook in
to the database, and where more work may be needed.

The output of the program is a simple ahnentafel with the ahnentafel
number, node weight, and key and name of the ancestors.

tree_density - a LifeLines program
        by Jim Eggert (eggertj@atc.ll.mit.edu)
        Version 1,  15 February 1996
*/

global(plist)
global(mark)
global(anccounts)

proc include(person,anckey)
{
    if (person) {
        set(pkey,key(person))
        if (not(lookup(mark,pkey))) {
            set(skey,save(pkey))
            set(sanckey,save(anckey))
            insert(mark,skey,sanckey)
            set(count,lookup(anccounts,sanckey))
            insert(anccounts,sanckey,add(count,1))
            enqueue(plist,skey)
        }
    }
}

proc main ()
{
    table(mark)
    table(anccounts)
    list(plist)
    list(alist)

    getindimsg(from_person,
        "Enter person to compute relation from:")
    set(from_key,save(key(from_person)))
    call include(from_person,from_key)

    set(counter,0)
    set(nextcount,0)

    while (pkey,dequeue(plist)) {
        incr(counter)
        if (ge(counter,nextcount)) {
            print(d(counter)," ")
            set(nextcount,add(nextcount,100))
        }

        set(person,indi(pkey))
        set(anckey,save(lookup(mark,pkey)))
        if (not(strcmp(pkey,anckey))) {
            call include(father(person),save(key(father(person))))
            call include(mother(person),save(key(mother(person))))
        }
        else {
            call include(father(person),anckey)
            call include(mother(person),anckey)
        }
        children(parents(person),child,cnum) {
            call include(child,anckey)
        }
        families(person,fam,spouse,pnum) {
            call include(spouse,anckey)
            children(fam,child,cnum) {
                call include(child,anckey)
            }
        }
    }

    "Ahnentafel" col(10) "  weight" col(20) "key" col(28) "name"
    enqueue(plist,from_key)
    enqueue(alist,1)
    while (pkey,dequeue(plist)) {
        set(a,dequeue(alist))
        set(p,indi(pkey))
        if (f,father(p)) {
            enqueue(plist,save(key(f)))
            enqueue(alist,add(a,a))
        }
        if (m,mother(p)) {
            enqueue(plist,save(key(m)))
            enqueue(alist,add(a,a,1))
        }
        d(a) col(10) rjustify(d(lookup(anccounts,pkey)),8)
        col(20) key(p) col(28) name(p) "\n"
    }
}