Debian Codegraph @

reports/related_spouses.ll

raw
1 /*
2 * @progname related_spouses.ll
3 * @version 2.0
4 * @author Eggert
5 * @category
6 * @output Text
7 * @description
8
9 This program identifies spouses with known common ancestors. For each
10 marriage of related spouses, the spouses' names are printed, along
11 with the first common ancestor in each branch of the ancestry tree,
12 and the number of intervening generations for the husband and wife,
13 respectively.
14
15 related_spouses - a LifeLines program to identify related spouses
16 by Jim Eggert ([email protected])
17 Version 1, 31 March 1993 (first release)
18 Version 2, 15 March 1995 (use new set functions, generation numbers)
19
20 */
21
22 proc main() {
23 indiset(husb_ancestors)
24 indiset(wife_ancestors)
25 indiset(common_ancestors)
26 forfam(family,fnum) {
27 if (hubby,husband(family)) {
28 if (wifey,wife(family)) {
29 /* find common ancestors */
30 indiset(oneset)
31 addtoset(oneset,hubby,0)
32 set(husb_ancestors,ancestorset(oneset))
33 addtoset(husb_ancestors,hubby,0)
34 indiset(oneset)
35 addtoset(oneset,wifey,0)
36 set(wife_ancestors,ancestorset(oneset))
37 addtoset(wife_ancestors,wifey,0)
38 set(common_ancestors,intersect(husb_ancestors,wife_ancestors))
39 set(cnum,lengthset(common_ancestors))
40
41 /* find lowest common ancestors (common_ancestors - too_common_ancestors) */
42 if (cnum) {
43 /* Make wife ancestor generation table wcat */
44 indiset(wca)
45 set(wca,intersect(wife_ancestors,husb_ancestors))
46 table(wcat)
47 forindiset(wca,person,wgen,wnum) {
48 insert(wcat,key(person),wgen)
49 }
50
51 indiset(lowest_common_ancestors)
52 set(lowest_common_ancestors,
53 difference(common_ancestors,
54 ancestorset(common_ancestors)))
55 set(lca_length,lengthset(lowest_common_ancestors))
56 /* print out lowest common ancestors */
57 key(family) " "
58 key(husband(family)) " " name(husband(family))
59 " and "
60 key(wife(family)) " " name(wife(family))
61 "\n have " d(lca_length)
62 " lowest common ancestor"
63 if (gt(lca_length,1)) { "s" }
64 col(60) "hgen" col(70) "wgen\n"
65 forindiset(lowest_common_ancestors,lca,hgen,lnum) {
66 " " key(lca) " " name(lca)
67 col(60) d(hgen)
68 col(70) d(lookup(wcat,key(lca))) "\n"
69 }
70 }
71 }
72 }
73 }
74 }