## Graph Theory Lecture Notes 9

### Eulerian Trails and Tours

An eulerian trail in a graph is a trail that contains every edge of the graph.

An eulerian tour is a closed eulerian trail.

An eulerian graph is a graph that has an eulerian tour.

#### Königsberg Bridge Problem

Kaliningrad, Russia (Just north of Poland). Späziergang - a walk around town usually on Sunday afternoon.

Kneiphoff - the island in the Pregel River in Königsberg.

Theorem (Euler, 1736): A graph G has an eulerian tour if and only if G is connected up to isolated vertices and every vertex of G has even degree.

### An Algorithm for Finding Eulerian Tours

Arbitrarily select edges forming a trail until the trail closes at the starting vertex. If there are unused edges, go to a vertex that has an unused edge which is on the trail already formed, then create a "detour" - select unused edges forming a new trail until this closes at the vertex you started with. Expand the original trail by following it to the detour vertex, then follow the detour, then continue with the original trail. If more unused edges are present, repeat this detour construction.

Theorem (Euler): A graph G has an open eulerian trail if and only if G is connected up to isolated vertices and the number of vertices of odd degree is 2.

### Debruijn Sequences and Postman Problems

A bitstring of length 2n is called a (2,n)-deBruijn sequence if each of the 2n possible bitstrings of length n occurs exactly once as a substring, where wraparound is allowed.

Examples: 0110 is a (2,2)-deBruijn sequence, 01110100 is a (2,3)-deBruijn sequence.

A (2,n)-deBruijn digraph D2,n consists of 2n-1 vertices, labeled by the bitstrings of length n-1, and 2n arcs, labeled by the bitstrings of length n. The arc from b1b2...bn-1 to b2...bn-1bn is labeled b1b2...bn.

Proposition 6.2.1: The (2,n)-deBruijn digraph D2,n is eulerian.

The sequence of leftmost bits on the arc labels of any eulerian tour of the (2,n)-deBruijn digraph is a (2,n)-deBruijn sequence.

Postman Tours

Street Sweeping

### Hamiltonian Paths and Cycles

A hamiltonian path (cycle) of a graph is a path (cycle) that contains all the vertices.

A hamiltonian graph is a graph that has a hamiltonian cycle.

Sir William Rowan Hamilton (1805-1865) and the Icosian Game.

Determining whether or not a graph is hamiltonian is an NP-complete problem.

Theorem 6.3.1 (Ore, 1960): Let G be a simple n-vertex graph, where n 3, such that deg(x) + deg(y) n for each pair of non-adjacent vertices x and y. Then G is hamiltonian.

Ore's theorem gives a sufficient, but not necessary condition for a graph to be hamiltonian. Consider a cyclic graph with 5 or more vertices.

Corollary 6.3.2 (Dirac, 1952): Let G be a simple n-vertex graph, where n 3, such that deg(v) ½n for each vertex v. Then G is hamiltonian.

### Gray Codes and Traveling Salesman Problems

A Gray code of order n is an ordering of the 2n bitstrings of length n such that consecutive bitstrings differ in precisely one bit position.

Recall that the n-dimensional hypercube graph Qn is the graph whose vertices are the length n bitstrings and two vertices are adjacent if and only if they differ in exactly one bit position. Therefore, a Gray code of order n corresponds to a hamiltonian cycle in Qn.

Theorem 6.4.1: The n-dimensional hypercube Qn is hamiltonian for all n 2.

Proof: by induction.

Thus, Gray codes exist for all orders (n=1 is trivial, the rest can be obtained from Qn).

Gray codes are useful in data transmission.

Traveling Salesman Problem

Given a graph having edge weights, the TSP is to find a hamiltonian cycle with minimum edge weight sum. The graph can always be assumed to be a complete graph by adding missing edges to the given graph and assigning them extremely large weights.

The TSP is an NP-hard problem. To solve instances of it various heuristic methods have been developed. Two such are the nearest neighbor (greedy) algorithm and the doubling the tree algorithm.