Subtrees and sublevels
First, here are some more handy keyboard shortcuts.
Up to now, inserting a child or sibling node has always meant appending one to the end of the appropriate subtree. It may often be more convenient to insert a child node at the top of the subtree, or a sibling node above the target node instead of below.
Click Tree on the main menu bar and move down to Insert, which will open a submenu. (From now on this menu path will be shortened to Main menu: Tree⁄Insert ). You will see the following commands:
Insert ⁄ Child node at bottom (of subtree) Ins(ert). We have already covered this one.
Insert ⁄ Child node at top (of subtree) Ctrl+Ins(ert). This will insert the child node at the top of the subtree, above the other child nodes. The shortcut key is Ctrl+Insert.
Insert ⁄ Node below (target node) Shift+Ins(ert). This inserts a sibling node below the node selected; we have already covered this. Although we used the Enter key to create the node, Shift+Insert is a widely used alternative. But who wants to press two keys when one will do?
Insert ⁄ Node above (target node) Shift+Ctrl+Ins(ert). This will insert the sibling node above the selected target node.
Now let's practice adding some more nodes to our tree, using whichever commands seem most convenient.
That's enough for the time being! Let's examine the relationships between them.
Parents, children, ancestors and descendants
Just as A, B and C are said to be child nodes of the Root node, so the Root node is parent to them. Note that in TreePad a parent node can have more than one child node, but no child node can have more than one parent. This type of tree has been termed a one-to-many tree.
We can extend the family analogy (remember, it is just an analogy!) to say that the Root node is the ancestor of any node more than one generation removed from it, which may similarly be termed a descendant. There is only one node (the Root node) at the top level of the tree. The next sublevel contains A, B, C, the one after that A1, A2 and B1, and the lowest sublevel consists of B1a and B1b.
Just as our main tree has a Root node and child nodes, any node that has its own child nodes forms a subtree. Nodes A and B are both root nodes of their respective subtrees. Node A's subtree is only one level deep, while node B's subtree is two levels deep. Here we will spell the "root" in "root node" with a small "r" to distinguish it from the Root node of the main tree. It will often be more useful to refer to A as the root node of its subtree (which contains A1 and A2) rather than the parent of A1 and A2, although both are true.
Just as a branch cut off a tree and held upright resembles a miniature tree, so a subtree is hardly different from the main tree except in complexity. Conversely, TreePad's main tree may be regarded as a special case of one of its subtrees; special in that its Root node may not have parents or siblings. So any command (such as sorting) that can be applied to the root node of a subtree affects the whole tree when applied to the Root node!
That concludes this section. Just remember these points:
- The Root node is created only by TreePad and cannot be deleted.
- The Root node cannot have any parent or sibling nodes.
- A subtree is not just the sibling nodes at that level but also includes their parent (the subtree's root node).
- A node can have only one parent.