-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
Priority/2-LowTo do after P1To do after P1Size/DaysSome days of workSome days of workStatus/ReadyForDevThe issue is ready to be developed or to be investigated deeplyThe issue is ready to be developed or to be investigated deeply
Description
Description
Currently the TreeNode class contains only a reference to a parent. This is very unusual for a tree structure, and while still it is possible to traverse it requires consulting the TreeNode list every time or preindexing.
Having child references would simplify the traversal for this structure.
Questions/Ideas
- After reading the object, index the
TreeNodenodes with a tuplechildrencontaining the references to the child nodes. - Indexation example
# This uses the fact that the node list is in BFS
nodes_index = {}
for node in tree.nodes:
nodes_index[node.id] = node
node.left_child = None
node.right_child = None
if node.parent_id is not None:
parent_node = nodes_index[node.parent_id]
if parent_node.left_child is None:
parent_node.left_child = node
else:
parent_node.right_child = nodepopescu-v
Metadata
Metadata
Assignees
Labels
Priority/2-LowTo do after P1To do after P1Size/DaysSome days of workSome days of workStatus/ReadyForDevThe issue is ready to be developed or to be investigated deeplyThe issue is ready to be developed or to be investigated deeply