Skip to content

Add a "fake root" to the tsk_tree struct #1691

Closed
@jeromekelleher

Description

@jeromekelleher

When writing algorithms with the quintuply linked tree structure for trees that contain multiple roots, it's quite tedious that we need to do things like

for root in tree.roots():
     do_algorithm(root)

It would be nicer if we could do something like

do_algorithm(tree.fake_root)

(I don't like the term fake_root but can't think of anything better).

The way this would be implemented in terms of the quintuply linked tree would be to add one more element to the pointer arrays, and to let this value (num_nodes) correspond to the ID of the fake root. Then, tree.left_child_array[-1] would correspond to the left root, etc.

This is a breaking change in terms of the low-level details of how we do tree traversals etc in C, so I think it would be good to get it done before 1.0.

Metadata

Metadata

Labels

C APIIssue is about the C APIenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions