Introduction to Graph Theory (2)

https://blog.csdn.net/saltriver/article/details/54428750

From the blog above

Daniel is a Daniel, and the combination of pictures and texts is easy to understand

Once the understanding of graph is established, "tree" is easy to understand. A "tree" is a very special kind of graph. Use a graph to define a "tree": a graph that is connected between any 2 points and has no "rings". The following graph is a tree, so a tree is a special case of a graph.


Tree:

1. Node

It is the vertex of the graph. 

2. Branch (branch) 

It is the edge of the graph.

3. Root (root) 

A tree can be imagined as branching from a certain vertex, then this vertex is the "root". Every node of a tree can be used as a root.

4. Leaf 

After selecting the root in a tree, such as node 0 as the root. Branching starts from the root, and all nodes that cannot be branched on the way become leaves. As shown in the figure below, the root is point 0, then nodes 2, 4, 6, and 7 are leaves.

5. Degree 

The number of subtrees a node has is called the degree of the node. A leaf can also be defined in degrees: a node with a degree of 0 is called a leaf.

Sixth, level/depth/height (level/depth/height) 

After selecting the root in a tree, the points in the tree can be divided into multiple levels according to the distance of each point from the root. The maximum number of levels in a tree is called the depth or height of the tree. The difference between a node and the maximum number of levels of the leaf below is called the height of the node.

7. Parent/child/sibling 

After selecting the root (root) in a tree, the two adjacent points, the one near the root is the parent (parent), and the one farther away is the child (child).

8. Ancestor/descendant 

After selecting the root (root) in a tree, the parents of a point, the parents of the parents, ... are all the ancestors of this point. The root node is the ancestor of all child nodes. Note that the parents also belong to ancestor. So ancestor is a set concept. Similarly, children of a point, children of children, ... are all descendants of this point, and descendants are also a collective concept. 

9. Forest 

A collection of many trees is called a forest. In a forest, trees do not intersect with each other.

In addition, like the graph, the tree also has concepts such as "directed/undirected", "isomorphism", "weight", "path", etc. The meaning is similar to that of the graph, so I won't repeat it. 
Finally, to summarize: 
1. All points in the tree are connected; 
2. There is only one path between any 2 points in the tree; 
3. A tree is a connected graph without a cycle; 
4. A forest is a disconnected graph without a cycle.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324607621&siteId=291194637