Basic terminology of graphs and graphs

One, the definition of the picture

FIG G by the two set V and E composition, referred to as G = (V, E), where V is the apex of a finite non-empty , V E is the apex of the coupling of a finite set .
Popular understanding: V is a collection of vertices (cannot be empty), E is a collection of edges (can be empty).
Directed graph : If the edge set E is a directed edge, then the graph is a directed graph, <x,y> x is the starting point of the directed edge (also called the arc tail), and y is the end point of the directed edge (also called Is arc head);
undirected graph : if the edge set E is an undirected edge, the graph is an undirected graph, and (x, y) and (y, x) are the same edge;

Second, the basic terminology of graphs

1. Subgraph :
Insert picture description here
2. Undirected complete graph : For an undirected graph, if there are n(n-1)/2 edges, it is called an undirected complete graph;
directed complete graph : For a directed graph, if there is n(n-1) arcs are called directed complete graphs;
3. Weights and nets : each edge can be marked with a value with a certain meaning, and this value is called the weight on the edge, weighted The picture is called a net.
4. Adjacent point : For an undirected graph, if the edge (v, v') of the graph belongs to E, then v and v'are called adjacent points.
5. Degree, In Degree and Out Degree : The degree of a vertex refers to the number of edges associated with the vertex. For a directed graph, the number of directed edges pointing to the vertex is the in-degree, and the number of directed edges pointed out from the vertex is called the out-degree of the vertex.
6. Path length : the length of the side or arc passed on a path;
7. Loop or loop : The length of the path where the first vertex and the last vertex are the same is called loop or loop;
8. Simple path, simple loop or simple loop : The path where the vertices do not reappear in the sequence is called a simple path; except for the first and last vertices, the paths where the vertices do not reappear are called simple loops or simple loops;

Three, the storage structure of the graph

1. The adjacency matrix

Insert picture description here
2.
Insert picture description here
Adjacency list The advantages and disadvantages of the adjacency list:
(Advantages)
1. It is convenient to add and delete vertices;
2. It is convenient to count the number of edges. Scan all edge tables in the order of the vertex table to get the number of edges. The time complexity is O(n +e);
3. High space efficiency;
(disadvantages)
1. It is not convenient to judge whether there are edges between vertices.
2. It is not convenient to calculate the degree of each vertex of a directed graph.
3. Cross linked list
Insert picture description here
4. Adjacent multiple lists.
Adjacent multiple lists are none. Another chain storage structure of the graph

Fourth, the traversal of the graph

1. Depth-first search
(1) Start from a vertex v in the graph and start visiting;
(2) Find the first unvisited neighbor of the vertex just visited and visit the vertex. Taking this vertex as the new vertex, repeat the next step until the vertex just visited has no unvisited neighboring points;
(3) Return to the previously visited vertex that still has unvisited neighboring points, and find Get the next unvisited neighbor of the vertex and visit the node;
(4) Repeat steps (2) and (3) until all vertices in the graph have been visited, and search results.
Insert picture description here
2. Breadth-first search
(1) Starting from a certain vertex in the graph, start to visit;
(2) Visit each of v's unvisited neighbors in turn ; (3) Start
from these neighbors and visit their neighbors in turn, And make the "adjacent point of the vertices visited first" be visited before the "adjacent points of the vertices visited later".
Insert picture description here

Guess you like

Origin blog.csdn.net/gets_s/article/details/106297669