Nodes, branches, roots, leaves, degree, level / depth / height, parent / child / sibling, ancestor / descendant, forest

The establishment of a knowledge map (graph), the "tree" like to understand. "Tree" is a very special FIG (graph). Fig defined "tree": all communication between any two points, and does not "ring" of FIG. The following diagram is a tree, and therefore, the tree is a special case of FIG. Of course, since the tree is a particularly useful data structure, therefore, it has its own features and concepts:  a node (node) is the figure (Graph) vertices (vertex). The above figure vertex: 0,1,2,3,4,5,6,7,8. Second, the branches (Branch) side is the FIG (Graph) of the (edge). The above figure 0-> 1, 0> 3, 0-> 5, 1-> 2, 1-> 4, 3-> 6, 5> 8, 8> 7. Third, the root (root) tree branches begin to imagine from one vertex, then this vertex is the "root." Each node of the tree can be used as a root. It may be 0 in FIG as the root node. Four, leaf (Leaf) After selecting the tree root, such as the root node 0. Began to branch from the root, all the way nodes can no longer become a branch of leaves. Below, the root point is 0, the node is a leaf 2,4,6,7. Five degree (Degree) Number of sub-tree has a node of a node is referred to (degree). The figure, the root node 0 has three subtrees, of 3; node 1 has two sub-trees of 2; 3,5 nodes were only a sub tree of 1. Leaf (Leaf) costs may be defined: 0 degree is referred to as leaf nodes (leaf). 2,4,6,7 tree node has no children, is 0, so 2,4,5,7 leaf. Sixth, layer / depth / height (level / depth / height) After selecting the root (root) in the tree, the root of each point from a distance, can be divided into a plurality of points in the tree hierarchy. 
Write pictures described here 

 

 

 

Write pictures described here 
 

Write pictures described here 
 

Write pictures described here 
 

Write pictures described here 
The maximum depth of the tree is referred to a number of hierarchical tree (depth) or the height (height), such as the depth of the tree (height) of 4. Leaf node to a height below the level of the difference between the maximum number of the called nodes (height), such as a node located on the 1, 2, 4 located on the lower leaves 2, the height of the node 1 is 1; Similarly, node 3 is a height, the height of the node 5 is 2, the node is a leaf 2 itself, the height is 0, 0 is the height of the root node 3. 
Seven, parent / child / sibling (parent / child / sibling) selected in the tree after the root (root), adjacent two points, close to the root of both parents (parent), a little further is the child (child) . As the figure above, 0 is the parents (parent) 1, and 2, 4, 1 child (child). 2,4 have a common parent, and therefore called each other brother (sibling) between 2 and 4. Similarly, parents 3 is 6, 6 children 3; 5 parents 8 8 5 children. 1,3,5 child is 0, 1,3,5 called each other brothers. Eight ancestor / descendant (ancestor / descendant) After selecting the root (root) in a tree, the parents of a point, parents of the parents, ...... are the ancestors of this point (ancestor), is the root of all child nodes ancestors, pay attention to parents (parent) also belongs to the ancestors. Therefore, the ancestor is a collective concept. Similarly, the child of a point, children's children, ...... are the descendants of this point (descendant), the offspring is a collective concept. Nine, forest (forest) collection of a lot of pieces of the tree is called a forest. Forest, disjoint tree to tree. In addition, like FIG, trees are "directed / undirected", "homogeneous", "weight", "route" and so on, similar to FIG meaning, omitted. Under concluded:  1. the tree are all the communication points;  there is only one path between any two points 2. tree;  

Write pictures described here 


 

 

Write pictures described here 




3. The tree is an acyclic FIG communication; 
4. Forest acyclic non-communicating FIG.

Published 66 original articles · won praise 1 · views 1172

Guess you like

Origin blog.csdn.net/qq_16933601/article/details/103325341