Data Structure 4 Figure

Please click here to enter image description

1. A graph is a mathematical object that represents the relationship between objects and is the basic research object of graph theory. Here is just the most basic things to understand. If every edge of a graph is directional, then the graph is called directed, otherwise it is undirected. Then, if, in an undirected graph, each pair of vertices is connected by one edge, or in a directed graph, each pair of vertices is connected by two directed edges, it is called a complete graph.

2. There are two ways to traverse the graph: depth-first and breadth-first.

Please click here to enter image description

For the structure of the above figure, if the depth-first traversal is adopted, the starting vertex V is first visited, and then any adjacent point W of V is searched from V in turn. If W has not been visited, the depth-first traversal will continue from this point. . The traversal results can be: V1, V2, V4, V8, V5, V3, V6, V7.

If the breadth-first traversal is adopted, the starting vertex V is visited first, then all the unvisited vertices W, X, Y... adjacent to the vertex V are visited, and then the unvisited vertices adjacent to W, X, Y... are visited in turn , so the traversal result can be: V1, V2, V3, V4, V5, V6, V7, V8.

3. The biggest difference between a graph and a tree is that the former has cycles. The process of converting a graph to its minimum spanning tree is to remove some of the edges in the graph to make it the tree with the smallest weight.

 

Guess you like

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