AbstractTrees.jl icon indicating copy to clipboard operation
AbstractTrees.jl copied to clipboard

Don't assume stored children

Open goretkin opened this issue 4 years ago • 4 comments

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}.

goretkin avatar May 19 '20 16:05 goretkin

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?

Keno avatar Aug 20 '21 05:08 Keno

Backtracking pointers in dynamic programming, e.g. storing the prev vertex is the use case I have in mind.

goretkin avatar Aug 20 '21 05:08 goretkin

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.

Keno avatar Aug 20 '21 05:08 Keno

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.

goretkin avatar Aug 20 '21 05:08 goretkin