AbstractTrees.jl
AbstractTrees.jl copied to clipboard
Don't assume stored children
There's a trait for ParentLinks
and SiblingLinks
, it would be great if there was a ChildrenLinks
trait too. Of course, a tree needs at least one of {link to children, link to parent}.
I think this is potentially reasonable, but a lot of the appeal of this package is the printing (and a very distant second the tree traversal code), neither of which you can do without being able to retrieve children. Do you have a particular usecase in mind?
Backtracking pointers in dynamic programming, e.g. storing the prev
vertex is the use case I have in mind.
How would that application benefit from generic code written with other kinds of trees in mind? I guess I'm trying to figure out if those kinds of trees really fit in.
I don't have a good answer to that question unfortunately. I think it had struck me as a natural generalization, however I see your point.
An iterator from node to root (which I believe this package does not provide yet) would work on trees without children links.
There could also be functions to convert between representations.