Tree Structure

1 Usages of Tree Structure

Tree structure is one of basic data structure which presents one type of nonlinear logic.

Tree structure can describe relationships in hierarchy and membership accurately.

2 Features of Tree Structure

2.1 Concepts

Information can be organized as a tree:

  1. "Node" stores a piece of information.
  2. "Children Nodes": In lower level and belong to the node. Also called "Branches".
  3. One node can have multiple children.
  4. "Parent Node": In higher level and owns the node.
  5. One node can have only one "Parent".
  6. "Descendant Nodes": All lower nodes extended recursively from children.
  7. "Ancestral Nodes": All higher nodes extended recursively from parent.
  8. "Root Node": In top level and be ancestry of all other nodes.
  9. "Leaf Nodes": Have not children.
  10. "Hierarchy Number": The chain of sequence numbers from root to the node.
  11. "Node Name": String to describe the node.
  12. "Chain Name": The chain of node names from root to the node.
  13. "Steady Node Name": During the tree is being watched or handled, node name is not changed.
  14. "Static Tree": During the tree is being watched or handled, tree structure is not changed, that is no node is deleted, added, or moved.
  15. "Dynamic Tree": During the tree is being watched or handled, tree structure is changed, that is some nodes are deleted, added, or moved.

2.2 Identify and Locate Nodes

To locate specific node in the tree correctly:

2.3 Ordered Tree

"Ordered Tree" has following features:

So hierarchy number can be used to locate a node only for static ordered tree.

2.4 Tree with Unique Chain Names

"Tree with unique Chain Names" has following features:

So chain names can be used to locate nodes for dynamic or static tree when it is "unique chain names".

3 Implement Tree Structure

In MyBox, attributes of tree node include: ID, Title(Node Name), Value, Modify_Time, ID of parent node.

3.1 ID of Node

ID of node is generated and increased automactically, and used to identify and locate each node uniquely. It is absolutely steady attribute:

IDs of nodes have following disadvantages:

3.2 Title of Node

Title of node is string to describe node:

Because titles of children can be duplicated, if treat node title as node name, then chain name may not be unique and can not locate node correctly with it.

Titles of nodes have following advantages:

3.3 Value of Node

Value of node is stored as large text of length 2G.

In MyBox, objects handled by following functions are stored and managed in tree:

MyBox Function Format of node value
Notes Html codes
Tree Information Text
Favorite Address Two fields: Address, Icon
Image Scope Definition of image scope in XML
Row Filter Three fields: JavaScript expression, Whether invert, Maximum rows
Define Data Data attributes and columns in XML
SQL Text: SQL statements
Math Function Four fields: Function Name, Variables, Expression, Domain
JavaScript Text: JavaScript codes
JShell Text: Java codes
JEXL Three fields: Script, Context, Parameters

3.4 Tags of Node

3.5 Reserved Strings

4 Manage Tree Structure

4.1 Tree View

Select one node, and display its "Tree View" with this node as root:

4.2 Examples

MyBox provides examples for functions in tree.
Click menu item "Examples" to import example data of the function.

Examples' tree view of of each function tree can be viewed in MyBox documents list.

4.3 Export

Select one node, and export its tree with this node as root:

4.4 Import

Tree information can be imported in batch:

Notice:

4.5 Query and Select Nodes

To select nodes, following ways can be taken:

4.6 Add/Delete/Modify Nodes

Select one or multiple nodes, and:

4.7 View Nodes

Select one node:

4.8 Menu