Closed theosanderson closed 2 years ago
Thanks for reaching out! This behavior is expected: the only guarantee of a preorder traversal is that you will visit a parent node before you visit its children, but beyond that restriction, nodes can be visited in any order. Thus, there's no guarantee that the nodes will be visited in the same order across tools (or even the same tree in the same tool, but with children rotated)
Thank you, sorry for the noise!
(sorry fat finger hit reopen and posted a half-written comment)
For info some sources do suggest that pre-order is a defined ordering https://en.m.wikipedia.org/wiki/Tree_traversal, mentions pre-order and reverse pre-order (right before left). It could be worth clarifying in the docs that this isn't this type of defined pre-order. (But this may well be context-dependent and I'm new to tree-stuff!) Thanks again for explaining this.
Thanks for sharing! In fully bifurcating trees, because every internal node has exactly 2 children, the only two ways of defining a preorder would be Visit-Left-Right or Visit-Right-Left, hence the ability to name them. However, this does not generalize to multifurcating trees (which TreeSwift assumes support for) nor does it really apply to phylogenies (because "left" and "right" don't really have meaning, as child order in a phylogeny is arbitrary)
If you're interested in tree algorithms (or data structures in general), be sure to check out my textbook 😄 It covers the various simple tree traversal algorithms but also discusses quite a few other data structures and their algorithms
Haha, thanks, and sorry
Thank you for this package!
I've been having some issues with pre-order traversal. I think it's possible that nodes appear in the wrong order, or at least a different order to Dendropy.
Let me know if I have this wrong. Thanks again!