Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorial on edge_diffs / incremental algorithms #233

Open
hyanwong opened this issue Mar 1, 2023 · 1 comment
Open

Tutorial on edge_diffs / incremental algorithms #233

hyanwong opened this issue Mar 1, 2023 · 1 comment

Comments

@hyanwong
Copy link
Member

hyanwong commented Mar 1, 2023

There's a lot of idioms and complicated code when implementing incremental algorithms, for example, that use the edge_diffs() iterator. For example it's a common idiom to iterate jointly over trees and edges diffs:

for tree, diffs in zip(ts.trees(), ts.edge_diffs()):
    ...

When going through the edge diffs, it is also often useful to keep track of which nodes come in and out of the tree (and hence maintain a list of "active" nodes). For example, I think this is what I need for tskit-dev/tskit#2718. I've done this sort of thing before, but forgotten the code that I used to do it. A tutorial might be a good place to put example code for people to modify. I assume it would be linked to from the "Fundamental operations" tute mentioned in #203

@hyanwong
Copy link
Member Author

hyanwong commented Mar 1, 2023

Ah yes, I remember, this sort of tallying of nodes when passing over edge_diffs (and in this case, counting sample numbers under them), was what I did when implementing the spans_by_samples function in tsdate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant