fix: correct Wright COI algorithm — handle direct parent-offspring pairings #44
Reference in New Issue
Block a user
Delete Branch "fix/coi-direct-ancestor-logic"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
The Trial Pairing Simulator showed 0.00% COI / 0 common ancestors even when the selected sire is a direct parent of the dam (or vice versa).
Root Cause
The old
calculateCOIcalledgetAncestors(sireId)andgetAncestors(damId), which started traversal at the parents of each dog (generation 1+). This meant the sire and dam themselves were never included in each other's ancestor maps, so a direct parent-offspring relationship was invisible to the algorithm.Example
getAncestors(River)→ River's parents, grandparents…getAncestors(dog2)→ River (gen 1), Willow (gen 1), …Fix
Rewritten
calculateCOIwith a propergetAncestorMap()that:Wright formula applied per path:
Result for River × dog 2:
Additional improvements
processedPathsSet prevents double-counting identical pathsFiles Changed
server/routes/pedigree.js—calculateCOIfunction completely rewritten