The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998 The.Algorithm.Design.Manual.Springer-Verlag.1998

18.04.2013 Views

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]

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]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!