Graph Theory of Basic Models

shortest path problem

(Given a network of roads connecting several cities, find the shortest route from the specified city to each city.)

Algorithms involved:

  1. Greedy algorithm (from the local optimal solution to the global optimal solution)

    The basic idea of ​​the greedy algorithm is to proceed step by step starting from an initial solution of the problem. According to an optimization measure, each step must ensure that a local optimal solution can be obtained. Only one data is considered in each step, and its selection should satisfy the conditions of local optimization. If the next data and the partial optimal solution are no longer a feasible solution, the data will not be added to the partial solution until all the data are enumerated, or the algorithm can no longer be added.

  2. Kijkstra algorithm

    Dijkstra's algorithm uses breadth-first search to solve the single-source shortest path problem of a weighted directed or undirected graph, and the algorithm finally obtains a shortest path tree. This algorithm is often used in routing algorithms or as a submodule of other graph algorithms.

 

Minimum spanning tree problem

Minimum spanning tree concept: Now suppose there is a very practical problem: we want to establish a communication network in n cities, then we need to arrange n-1 communication lines to connect these n cities. At this time, we need to consider how to minimize the cost. In the case of establishing this communication network?
So we can introduce a connected graph to solve the problem we encountered. n cities are the n vertices on the graph, and then the edge represents the communication line between the two cities, and the weight on each edge is what we build this line. Therefore, now we have a connected network with n vertices to build different spanning trees, and each spanning tree can be used as a communication network. The spanning tree is called the minimum spanning tree.

  There are three criteria for constructing a spanning tree:
  <1> Only the edges in this network must be used to construct a minimum spanning tree.
  <2> Must use and only use n-1 edges to connect n vertices in the network
  <3> Cannot use edges that generate loops

Algorithms involved:

  Kruskal's algorithm:

  The basic idea of ​​Kruskal's algorithm is that the edge is dominant, and the least weighted edge that is currently available (the selected edge cannot form a loop) is always selected. So the first step of Kruskal's algorithm is to sort all the edges in ascending order.

  The specific implementation process is as follows

  <1> Let a connected network with n vertices be G(V, E), initially construct a non-connected graph T={V, empty} with only n vertices and no edges, each vertex in the graph is self-contained A grid of connected components.

 

  <2> When selecting an edge with the smallest weight in E, if the two vertices of the edge fall on different connected components, this edge is added to T; otherwise, the two vertices of this edge are If it falls on the same connected component, this edge is discarded (this edge will never be selected after this), and an edge with the smallest weight is selected again.

 

  <3> Repeat this until all vertices are on the same connected component.

 

China Postal Issues

Algorithms involved:

    Edmons-Johnson algorithm

staffing issues

Algorithms involved:

  Hungarian Algorithm (Bipartite Graph Assignment) 

  Due to the nature of the augmented path, there is always one more matching edge in the augmented path than the unmatched edge, so if we discard the matched edge in an augmented path and select the unmatched edge as the matched edge, the number of matches will be Increase. The Hungarian algorithm is constantly looking for an augmenting path. If the augmenting path cannot be found, it means that the maximum matching has been achieved.

  For example 
  1, there is no match at the beginning 

  2. Select the first x point to find the first connection 

 


  3. Select the second point to find the second line 

 


  4. It is found that the first edge x3y1 of x3 has been occupied, find the staggered path x3-y1-x1-y4 from x3, and remove the matching edge x1y1 in the staggered path from the matching, and the remaining Add edge x3y1 x1y4 to match 

 


  5. In the same way, add x4 and x5. 

  The Hungarian algorithm can be depth-limited or breadth-first. The example just now is depth-first, that is, x3 finds y1, and y1 already has a match, then finds an interleaved path. If it is breadth-first, it should be: x3 finds y1, y1 has a match, and x3 finds y2.

   

maximum flow problem

Algorithms involved:

  Ford-Fulkerson algorithm

  

  The maximum flow problem often occurs in logistics and distribution, and can be reduced to the following graph problem. In the maximum flow problem, a pair of opposite edges cannot exist simultaneously between two vertices in the graph.

  The number on the edge is the capacity of the edge, that is, the upper limit of the amount flowing on the edge. The maximum flow problem is to maximize the flow from the starting point s to the end point t under the condition of meeting the capacity constraints. Before introducing the Ford-Fulkerson method for solving the maximum flow problem, some basic concepts are introduced.

  1. Survival network and augmentation path

  The residual network that can draw a graph from the graph and the flow on each edge is shown below. The figure on the left is the flow network, and the figure on the right is the residual network, where the numbers on the edges in the flow network are the flow and capacity respectively, such as 10/12, then 10 is the flow on the edge, and 12 is the capacity of the edge. There may be a pair of opposite edges in the residual network, the same edge as in the flow network represents the remaining capacity of the edge in the flow network, and the edge that does not exist in the flow network represents its opposite in the flow network. The existing flow to the edge, this part of the flow can be reduced by "return". For example, in the residual network on the right, the residual capacity of the edge <s,v1> is 4, and the value of the reverse edge <v1.s> is 12, which is the flow of the edge <s,v1> in the flow network on the left. In the residual network, edges with value 0 are not drawn, such as edge <v1,v2>.

  The residual network describes the remaining capacity of each edge in the graph and the amount of traffic that can be removed by "reflow". In the Ford-Fulkerson method, it is precisely by finding an augmenting path from s to t in the residual network, and modifying the flow of each edge in the flow network corresponding to each edge on this path. If an edge on the path exists in the flow network, the flow to that edge increases, otherwise the flow to the opposite edge decreases. The value of the increase or decrease is determined, that is, the edge with the smallest value on the augmented path

  

traveling salesman problem

Algorithms involved:

  Genetic Algorithm

  Genetic algorithm is a general algorithm for solving search problems and can be used for various general problems. The common features of search algorithms are:
  ① First form a set of candidate solutions
  ② Calculate the fitness of these candidate solutions according to some adaptive conditions
  ③ Retain some candidate solutions according to the fitness, and discard other candidate
  solutions some operations to generate new candidate solutions.

 

 

 

Guess you like

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