// process parent-child relationships once all marriages are known void SetupParents(Family model) { var people = model.NodesSource as IList <Person>; foreach (var person in people) { var key = person.Key; var mother = person.Mother; var father = person.Father; if (mother != -1 && father != -1) { var mrel = FindMarriage(model, mother, father); if (mrel == null) { // or warn no known mother or no known father or no known marriage between them continue; } var mlabkey = mrel.LabelNode; var crel = new Relationship() { From = mlabkey, To = key, Category = "ParentChild" }; model.AddLink(crel); } } }
// now process the node data to determine marriages void SetupMarriages(Family model) { var people = model.NodesSource as IList <Person>; var numpeople = people.Count; for (int i = 0; i < numpeople; i++) { var person = people[i]; var key = person.Key; var uxs = person.Wives; if (uxs != null) { foreach (var wife in uxs) { if (key == wife) { // or warn no reflexive marriages continue; } var rel = FindMarriage(model, key, wife); if (rel == null) { // add a label node for the marriage link var mlab = new Person() { IsLinkLabel = true, Sex = "LinkLabel" }; model.AddNode(mlab); // add the marriage link itself, also referring to the label node var mrel = new Relationship() { From = key, To = wife, LabelNode = mlab.Key, Category = "Marriage" }; model.AddLink(mrel); } } } var virs = person.Husbands; if (virs != null) { foreach (var husband in virs) { if (key == husband) { // or warn no reflexive marriages continue; } var rel = FindMarriage(model, key, husband); if (rel == null) { // add a label node for the marriage link var mlab = new Person() { IsLinkLabel = true, Sex = "LinkLabel" }; model.AddNode(mlab); // add the marriage link itself, also referring to the label node var mrel = new Relationship() { From = key, To = husband, LabelNode = mlab.Key, Category = "Marriage" }; model.AddLink(mrel); } } } } }