/// <summary> /// Sets the nodes post and level order numbering. /// </summary> private void SetPostandLevelOrders() { int postOrderIndex = 0; foreach (BehaviourNode node in TreeTraversal.PostOrder(Root)) { node.postOrderIndex = postOrderIndex++; } foreach ((BehaviourNode node, int level) in TreeTraversal.LevelOrder(Root)) { node.levelOrder = level; Height = level; } }
/// <summary> /// Traverses the nodes under the root in pre-order and sets the tree nodes. /// </summary> /// <param name="root">The tree root</param> public void SetNodes(BehaviourNode root) { SetNodes(TreeTraversal.PreOrder(root)); }