ARG traversal: iterate over edges by child node #2744
hyanwong
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Traversing from bottom to top of a tree sequence, visiting the edges that belong to each parent, is easy, because edges are ordered by parent time (
itertools.groupby(ts.edges(), operator.attrgetter("parent"))
should do it). But It is often useful to traverse from top to bottom in a tree sequence, visiting the all the edges that nodes in age order. For example, we do this intsdate
, here.Here's a nice compact function to do this:
An example of using it:
Beta Was this translation helpful? Give feedback.
All reactions