The.Algorithm.Design.Manual.Springer-Verlag.1998
The.Algorithm.Design.Manual.Springer-Verlag.1998 The.Algorithm.Design.Manual.Springer-Verlag.1998
Eulerian Cycle / Chinese Postman Next: Edge and Vertex Connectivity Up: Graph Problems: Polynomial-Time Previous: Matching Eulerian Cycle / Chinese Postman Input description: A graph G=(V,E). Problem description: Find the shortest tour of G visiting each edge at least once. Discussion: Suppose you are given the map of a city and charged with designing the routes for garbage trucks, snow plows, or postmen. In all of these applications, every road in the city must be completely traversed at least once in order to ensure that all deliveries or pickups are made. For efficiency, you seek to minimize total drive time, or equivalently, the total distance or number of edges traversed. Such applications are variants of the Eulerian cycle problem, best characterized by the children's puzzle that asks them to draw a given figure completely without lifting their pencil off the paper and without repeating any edges. We seek a path or cycle through a graph that visits each edge exactly once. There are well-known conditions for determining whether a graph contains an Eulerian cycle, or path: ● An undirected graph contains an Eulerian cycle iff (1) it is connected and (2) each vertex is of even degree. ● An undirected graph contains an Eulerian path iff (1) it is connected and (2) all but two vertices file:///E|/BOOK/BOOK4/NODE165.HTM (1 of 4) [19/1/2003 1:31:06]
Eulerian Cycle / Chinese Postman are of even degree. These two vertices will be the start and end points of the path. ● A directed graph contains an Eulerian cycle iff (1) it is connected and (2) each vertex has the same in-degree as out-degree. ● Finally, a directed graph contains an Eulerian path iff (1) it is connected and (2) all but two vertices have the same in-degree as out-degree, and these two vertices have their in-degree and out-degree differ by one. Given this characterization of Eulerian graphs, it is easy to test in linear time whether such a cycle exists: test whether the graph is connected using DFS or BFS, and then count the number of odd-degree vertices. Actually constructing such a cycle also takes linear time. Use DFS to find a cycle in the graph. Delete this cycle and repeat until the entire set of edges has been partitioned into a set of edge-disjoint cycles. Since deleting a cycle reduces each vertex degree by an even number, the remaining graph will continue to satisfy the same Eulerian degree-bound conditions. For any connected graph, these cycles will have common vertices, and so by splicing these cycles in a ``figure eight'' at a shared vertex, we can construct a single circuit containing all of the edges. An Eulerian cycle, if one exists, solves the motivating snowplow problem, since any tour that visits each edge only once must have minimum length. However, it is unlikely that any real road network would happen to satisfy the degree conditions that make it Eulerian. We need to solve the more general Chinese postman problem, which minimizes the length of a cycle that traverses every edge at least once. In fact, it can be shown that this minimum cycle never visits any edge more than twice, so good tours exist for any road network. The optimal postman tour can be constructed by adding the appropriate edges to the graph G so as to make it Eulerian. Specifically, we find the shortest path between each pair of odd-degree vertices in G. Adding a path between two odd-degree vertices in G turns both of them to even-degree, thus moving us closer to an Eulerian graph. Finding the best set of shortest paths to add to G reduces to identifying a minimum-weight perfect matching in a graph on the odd-degree vertices, where the weight of edge (i,j) is the length of the shortest path from i to j. For directed graphs, this can be solved using bipartite matching, where the vertices are partitioned depending on whether they have more ingoing or outgoing edges. Once the graph is Eulerian, the actual cycle can be extracted in linear time using the procedure described above. Implementations: Unfortunately, we have not able to identify a suitable Chinese postman implementation. However, it should not be difficult for you to roll your own by using a matching code from Section and all-pairs shortest path from Section . Matching is by far the hardest part of the algorithm. Combinatorica [Ski90] provides Mathematica implementations of Eulerian cycles and de Bruijn sequences. See Section . file:///E|/BOOK/BOOK4/NODE165.HTM (2 of 4) [19/1/2003 1:31:06]
- Page 439 and 440: Generating Permutations generating
- Page 441 and 442: Generating Subsets look right when
- Page 443 and 444: Generating Subsets above for detail
- Page 445 and 446: Generating Partitions Although the
- Page 447 and 448: Generating Partitions Two related c
- Page 449 and 450: Generating Graphs generate: ● Do
- Page 451 and 452: Generating Graphs Combinatorica [Sk
- Page 453 and 454: Calendrical Calculations Next: Job
- Page 455 and 456: Calendrical Calculations Gregorian,
- Page 457 and 458: Job Scheduling ● To assign a set
- Page 459 and 460: Job Scheduling shop scheduling incl
- Page 461 and 462: Satisfiability logic, and automatic
- Page 463 and 464: Satisfiability Next: Graph Problems
- Page 465 and 466: Graph Problems: Polynomial-Time rec
- Page 467 and 468: Connected Components Testing the co
- Page 469 and 470: Connected Components discussing gra
- Page 471 and 472: Topological Sorting contradiction t
- Page 473 and 474: Minimum Spanning Tree Next: Shortes
- Page 475 and 476: Minimum Spanning Tree help you sort
- Page 477 and 478: Shortest Path Next: Transitive Clos
- Page 479 and 480: Shortest Path easier to program tha
- Page 481 and 482: Shortest Path Related Problems: Net
- Page 483 and 484: Transitive Closure and Reduction
- Page 485 and 486: Transitive Closure and Reduction Al
- Page 487 and 488: Matching augmenting paths and stopp
- Page 489: Matching Combinatorica [Ski90] prov
- Page 493 and 494: Eulerian Cycle / Chinese Postman Ne
- Page 495 and 496: Edge and Vertex Connectivity Severa
- Page 497 and 498: Edge and Vertex Connectivity Next:
- Page 499 and 500: Network Flow programming model for
- Page 501 and 502: Network Flow Combinatorica [Ski90]
- Page 503 and 504: Drawing Graphs Nicely vertices are
- Page 505 and 506: Drawing Graphs Nicely labs.com/orgs
- Page 507 and 508: Drawing Trees such as the map of th
- Page 509 and 510: Planarity Detection and Embedding N
- Page 511 and 512: Planarity Detection and Embedding p
- Page 513 and 514: Graph Problems: Hard Problems ● C
- Page 515 and 516: Clique approximate even to within a
- Page 517 and 518: Independent Set Next: Vertex Cover
- Page 519 and 520: Independent Set Related Problems: C
- Page 521 and 522: Vertex Cover Vertex cover and indep
- Page 523 and 524: Traveling Salesman Problem Next: Ha
- Page 525 and 526: Traveling Salesman Problem practice
- Page 527 and 528: Traveling Salesman Problem Size is
- Page 529 and 530: Hamiltonian Cycle Eulerian cycle, p
- Page 531 and 532: Graph Partition Next: Vertex Colori
- Page 533 and 534: Graph Partition annealing, is almos
- Page 535 and 536: Vertex Coloring Several special cas
- Page 537 and 538: Vertex Coloring Notes: An excellent
- Page 539 and 540: Edge Coloring The minimum number of
Eulerian Cycle / Chinese Postman<br />
Next: Edge and Vertex Connectivity Up: Graph Problems: Polynomial-Time Previous: Matching<br />
Eulerian Cycle / Chinese Postman<br />
Input description: A graph G=(V,E).<br />
Problem description: Find the shortest tour of G visiting each edge at least once.<br />
Discussion: Suppose you are given the map of a city and charged with designing the routes for garbage<br />
trucks, snow plows, or postmen. In all of these applications, every road in the city must be completely<br />
traversed at least once in order to ensure that all deliveries or pickups are made. For efficiency, you seek<br />
to minimize total drive time, or equivalently, the total distance or number of edges traversed.<br />
Such applications are variants of the Eulerian cycle problem, best characterized by the children's puzzle<br />
that asks them to draw a given figure completely without lifting their pencil off the paper and without<br />
repeating any edges. We seek a path or cycle through a graph that visits each edge exactly once.<br />
<strong>The</strong>re are well-known conditions for determining whether a graph contains an Eulerian cycle, or path:<br />
● An undirected graph contains an Eulerian cycle iff (1) it is connected and (2) each vertex is of<br />
even degree.<br />
● An undirected graph contains an Eulerian path iff (1) it is connected and (2) all but two vertices<br />
file:///E|/BOOK/BOOK4/NODE165.HTM (1 of 4) [19/1/2003 1:31:06]