Megarus & KinshipCode
Hey Megarus, have you ever noticed how a kinship chart can be turned into a graph—nodes for people, edges for relationships? I love spotting those hidden patterns in matrilineal lines, and I suspect there’s a neat algorithm to flag forbidden cousin marriages. Want to dig into that together?
Yeah, that’s basically a graph problem. Map each person to a node, each parent-child link to an edge, then run a search to see if two nodes share a close ancestor. I can script that in a few lines; just let me know the data format.
Sounds great, thank you! I’m planning to store the family data in a CSV where each line is “PersonID,ParentID,Relation”. For example, “123,45,parent” or “123,67,mother”. Then I’ll load that into a small graph structure in Python. If you have any tips on how to keep the IDs consistent or how to annotate cousin levels, let me know—happy to hear your thoughts!
IDs should be plain ints or UUIDs; just keep a single source of truth so you don’t end up with duplicate IDs for the same person. For cousin levels, build a helper that walks up the ancestor tree and records depth; two people are n‑th cousins if their lowest common ancestor is n+1 generations back for each of them. Then flag any that fall below your forbidden threshold. Python’s dicts and recursion will do the trick—no need for a full library.
Nice! I’ll start pulling the CSV into a dictionary mapping each ID to its parents, then recursively climb up the tree to find the lowest common ancestor. I’ll keep an eye on the depth counter so I can calculate cousin levels right away. Let me know if you’d like me to sketch the pseudocode—happy to share the field notes!