Graphs are useful for characterizing two interesting problems: the traveling salesman problem, and the highway inspector problem. The problem in each case is to traverse a network in an optimal way, whether the focus is on the nodes (Sir William Rowan Hamilton, 1805-1865) or the arcs (Leonhard Euler, 1707-1783).
Definition: an Euler Path is a path in which each arc is used exactly once. Also known as the highway inspector problem, and the
Euler got interested in these arcs when he encountered the Königsberg bridge problem (p. 421/425); a game in which the object was to cross every bridge without crossing any bridge twice. Euler solved this problem by inventing and then using Graph Theory, basically!
The bridges are the arcs, and the land masses are nodes, turned into the graph of Figure 6.5, p. 421/426.
To do: Practice 7, p. 421/426
Theorem: in any graph, the number of odd nodes (nodes of odd degree) is even.
Outline of proof:
and the left hand side is even (call it 2m).
which means that was, in fact, even; but this is a contradiction. Hence, the number of odd nodes is even.
Theorem: an Euler path exists in a connected graph there are either two or zero odd nodes.
To do: Practice 9, p. 423/428
The EulerPath algorithm makes use of the adjacency matrix representation of a graph to check for Euler paths. It simply counts up elements in a row i of the matrix (the degree of node i), and checks whether that's even or odd; if in the end there are not zero or two even nodes, there's no Euler path!
To do: Exercise 11/12, p. 427/432
Definition: a Hamiltonian Circuit (or Cycle) is a cycle using every node of the graph.
``For example, consider a robot arm assigned to solder all the connections on a printed circuit board. The shortest tour that visits each solder point exactly once defines the most efficient path for the robot. A similar application arises in minimizing the amount of time taken by a graphics plotter to draw a given figure.'' (from http://www.cs.sunysb.edu/~algorith/files/traveling-salesman.shtml)
An example is a complete graph, like : there is a path from each node to every other node, so no matter where you start, you can trace a cycle through every node (breaks down for .
To do: Practice 11, p. 425/430
To do: Exercise 14/15, p. 427/432 (using trees, symmetry, and exhaustion!)
Unfortunately, there's no nice HamiltonCircuit algorithm for determining when there is a circuit (only very grungy, computationally intensive ones!). The traveling salesman problem (the optimal Hamiltonian Circuit on a weighted graph) is the poster child for the NP-complete problem.