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.
Euler got interested in these arcs when he encountered the Königsberg bridge problem (p. 421); 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.
To do: Practice 7, p. 421
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
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, p. 427
Definition: a Hamiltonian Circuit is a cycle using every node of the graph.
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
To do: Exercise 14, p. 427 (using trees, symmetry, and exhaustion!)
Unfortunately, there's no nice HamiltonCircuit algorithm for determining when there is a circuit (only very grungy ones!).