Pedigree topological order
See original GitHub issueMany pedigree algorithms require the topological ordering of nodes such that each individual occurs before its decedents. In sgkit it makes sense to simply calculate and store the topological order as an array of indices. This array can be calculated from the parent
array introduced in #839. There are several graph libraries which could be used to compute topological order https://github.com/pystatgen/sgkit/discussions/786#discussioncomment-1863520. Alternatively we could implement Kahn’s algorithm to avoid picking up another dependency (it’s quite simple).
Either way the API is quite simple e.g. topological_sort(ds, parent=parent)
-> ds
with topological_order
where topological_order
has dimension samples
and is of type uint64
. Suggestions for better names are welcome!
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top GitHub Comments
Great idea @timothymillar. I suspect it would be simpler to just implement this ourselves. We have an implementation in tskit we can compare against:
Done in #846