tskit icon indicating copy to clipboard operation
tskit copied to clipboard

TreeSequence.preorder(u) function

Open jeromekelleher opened this issue 3 weeks ago • 4 comments

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.

jeromekelleher avatar Nov 26 '25 16:11 jeromekelleher