📜  中国邮递员或路检|第 1 套(介绍)

📅  最后修改于: 2022-05-13 01:57:54.576000             🧑  作者: Mango

中国邮递员或路检|第 1 套(介绍)

中国邮递员问题是无向图的欧拉回路问题的变体。欧拉回路是一个封闭的步行,一旦开始和结束位置相同,它就会覆盖每条边。中国邮递员问题是针对连通图和无向图定义的。问题是找到至少访问图的每条边一次的最短路径或回路。

如果输入图包含欧拉电路,则问题的解决方案是欧拉电路
如果“所有顶点都具有偶数度”,则无向且连通图具有欧拉环。

中国邮递员

不管图是加权还是非加权,如果存在的话,中国邮递员路线总是与欧拉回路相同。在加权图中,邮递员旅行的最小可能权重是我们通过欧拉回路获得的所有边权重的总和。我们无法获得更短的路线,因为我们必须至少访问所有边缘一次。

如果输入图不包含欧拉电路
在这种情况下,任务减少到跟随。
1)在未加权图中,要复制的最小边数,以便给定图转换为具有欧拉循环的图。

中国邮递员2

2)在加权图中,要复制的边的最小总权重,以便给定图转换为具有欧拉循环的图。

中国邮递员3

Algorithm to find shortest closed path or optimal 
Chinese postman route in a weighted graph that may
not be Eulerian.
step 1 : If graph is Eulerian, return sum of all 
         edge weights.Else do following steps.
step 2 : We find all the vertices with odd degree 
step 3 : List all possible pairings of odd vertices  
         For n odd vertices total number of pairings 
         possible are, (n-1) * (n-3) * (n -5)... * 1
step 4 : For each set of pairings, find the shortest 
         path connecting them.
step 5 : Find the pairing with minimum shortest path 
         connecting pairs.
step 6 : Modify the graph by adding all the edges that  
         have been found in step 5.
step 7 : Weight of Chinese Postman Tour is sum of all 
         edges in the modified graph.
step 8 : Print Euler Circuit of the modified graph. 
         This Euler Circuit is Chinese Postman Tour.   

插图 :

3
        (a)-----------------(b)
     1 /  |                  |  \1
      /   |                  |   \
     (c)  | 5               6|   (d)
      \   |                  |   /
     2 \  |         4        |  /1
        (e)------------------(f)
As we see above graph does not contain Eulerian circuit
because is has odd degree vertices [a, b, e, f]
they all are odd degree vertices . 

First we make all possible pairs of odd degree vertices
[ae, bf], [ab, ef], [af, eb] 
so pairs with min sum of weight are [ae, bf] :
ae = (ac + ce = 3 ),  bf = ( bd + df = 2 ) 
Total : 5

We add edges ac, ce, bd and df to the original graph and
create a modified graph.

img038

Optimal chinese postman route is of length : 5 + 23 = 
28 [ 23 = sum  of all edges of modified graph ]

Chinese Postman Route :  
a - b - d - f - d - b - f - e - c - a - c - e - a 
This route is Euler Circuit of the modified graph. 

参考:
https://en.wikipedia.org/wiki/Route_inspection_problem
http://www.suffolkmaths.co.uk/pages/Maths%20Projects/Projects/Topology%20and%20Graph%20Theory/Chinese%20Postman%20Problem.pdf