tskit
tskit copied to clipboard
TreeSequence.preorder(u) function
This should equivalent to
all_descendants = []
for tree in ts.trees():
all_descendants = np.union1d(
all_descendants, np.sort(tree.preorder(alpha_origin["node_id"])))
But in graph preorder.
I think the algorithm is here: https://github.com/tskit-dev/tskit/discussions/2869#discussioncomment-7535830
We can add other traversal orders if they seem useful, but this seems like a good place to start. Return value is a numpy array.