For an exercise solution in this section, please refer to: HTTPS://SITES.GOOGLE.COM/SITE/ALGORITHMSSOLUTION/HOME/C22
first, the concept of the graph
Classification of graphs:
|
Whether there is a ring |
Whether there is a heavy edge |
Whether there is a forward edge |
| Simple undirected graph (simply no graph) |
X |
X |
X |
| Multigraph (multiple plots) |
X |
√ |
X |
| Pseudograph (pseudo graph) |
√ |
√ |
X |
| Simple Directed graph (plain graph) |
X |
X |
√ |
| Directed multigraph (with multiple graphs) |
√ |
√ |
√ |
| Mixed graph (mixed graph) |
√ |
√ |
There is a forward and a no-edge coexistence |
Infinite Graph: A graph with an infinite number of points.
finite Graph: A graph with a limited number of points.
Multiedge: Heavy side.
Isolated Vertex: A point with a degree of 0.
pendant Vertex: A point with a degree of 1.
pendant Edge: Connect the edges of the two suspension points.
full Picture (Kn): There is an edge between any two points.
complement of graph (complement map): and G have the same point, but if there is an edge in the fill map, there is no image.
Note the point:1, the small diagram is usually used adjacency matrix. 2, the general graph algorithm is the adjacency table. 3, the adjacency table storage space is O (v+e). 4, the adjacency matrix storage space is O (v^2). 5, for the graph, if the adjacency matrix storage, you can only store the main diagonal and the main diagonal above the section, you can save the general space. 6, with the Edge (U,V), the non-edge with {U,V} is indicated. 7, if it is a weighted graph, the adjacency table indicates that you can add a weight to each node of the adjacency table, and the adjacency matrix can be substituted with weights at the location of the cell. 8. There are two degrees of a ring in the graph without direction. 9. The sum (deg (v)) in the graph is =2e, so that the sum of the degrees must be an even number, and if the sum of the given degree sequence is odd, it is certainly not a non-graph. 10. Sum in the direction graph (deg-(v)) =sum (deg+ (v)) =| e|.
One thing to note about adjacency table representations is that if a is connected to B, C, D, the order of the adjacency table for a is indeterminate, possibly D, c, B, or C, D, B.
The following is the concept of a tree, but it is used when DFS, BFS generates depth-first tree, and breadth-first tree:
the ancestor of v: Includes true ancestors of V and v. V of
True Ancestors: If there is U (without v), so that you have a path to V, then U is the true ancestor of V. V of
Descendants: Includes true descendants of V and V. V of
true Descendants: If there is U (without v), so that V to U has a path, then U is a true descendant of V.
strongly connected graphs: Any two vertices u,v,u to V and V to u have paths.
Weakly connected graphs: This graph is a forward graph, he is not a strong connected graph, but if the forward edge is turned into an undirected edge, the graph is connected, then the graph is a weakly connected graph.
two-part diagram(bipartite graph): If the point set of a graph can be divided into two disjoint subsets of V1, V2, so that each edge is a point in the V1 and the point in the V2 connection.
complete two-part diagram: When a point set is divided into two subsets, each of the sub-sets is drawn with an edge.
coloring theorem: If the graph is a binary graph, and only if one of the red and blue colors is given to each point in the diagram, the two vertices without an edge are the same color. The coloring theorem can be achieved by BFS, where the vertices with odd distances are shaded in blue, even the vertex coloring is red, the coloring is completed by O (V+e), and then each edge is traversed to check if the coloring is correct, O (v+e). Theorem: A graph is a binary chart when and only if it is impossible to start from a vertex, and then go back to the starting point by an odd number of edges.
cut the dots.: If a point is removed and the number of connected branches increases, the point is a cut point.
Cutting Edge(bridge): If an edge is removed, the number of connected branches increases, the edge is cut edge.
Euro-Pull circuit: A simple loop that traverses each edge once is found in the diagram (note is a simple loop);
Euler path: A simple path to traverse each edge is found in the diagram;
In the diagram, there is Euler loop in the graph, and only if the degree of each vertex in the graph is even, in the direction graph, there is Euler loop in the graph, and only if the degree of each vertex in the graph is the same;
In an precise graph, there are Euler paths in the graph and only two vertices are odd in the graph, and in the direction graph, there is Euler path in the graph and only two points in the graph, the degree of the degrees difference is odd;
Hamilton Circuit: A simple loop that can traverse each point can be found in the diagram;
Hamilton Path: A simple path that can traverse each point is found in the diagram;
Connected Branches: A set of connected points, such as {a,b,c}, as a connected branch of the graph;
To determine the existence of a loop in an no-show diagram: | e|>| V|-1 and connected diagram, there must be a circuit. Determine if there is a loop in the graph: DFS has a reverse edge.
Second, BFS
Use: (1) Traverse diagram. (2) The shortest path is calculated on the premise that the weights of each side of the graph are 1.
Note: (1) any one edge (u,v),d[v]<=d[u]+1; (2) in the queue, set the team head is U, the tail of the team is v,d[v]<=d[u]+1;
The most important point: BFS can generate the shortest path tree, but not all shortest path trees can be generated by BFS. For example:
Third, DFS
Tree Side: The edge that appears in the depth precedence tree.
Forward Edge: U to the side of the non-direct descendants.
Reverse Edge: U to the side of the ancestors (including themselves).
Cross Edges: U and V are not ancestor-descendant relationships.
In an no-map, only the tree edges and the opposite edges.
Iv. topological sequencing
If present (u,v), then F[u]>f[v].
There are two implementations of topology sequencing:(1) Press f[] to descending DFS. (2) Every time you delete a point with an entry level of 0.