Section Project: Edges with Equal Weights
The weighted graphs presented in this chapter have all had the property that no two edges have the same weight. If, in the application of the greedy algorithms, there is more than one edge with minimal weight, we simply pick one of them at random. This means that we may get different outcomes depending on the choices we make. See how much variation there is in the outcomes when your class does the following problem.
Suppose that you need to make a delivery to each of 11 friends and then return home. What's more, your car is in very bad shape and you don't want to drive it any further than absolutely necessary. Call your house A and the houses of your friends B, C, D, E, F, G, H, I, J, K and L. Table 6.21 below indicates the distances between each pair of houses. You need to find a Hamilton circuit through the complete graph on 12 vertices, A, B, C, D, E, F, G, H, I, J, K and L, which has as small a total distance as possible. According to what you learned in Problem 6.9, you are quite certain that you don't want to use the Brute Force Algorithm to find this circuit.
Pick a random Hamilton circuit and compute its total length.
Apply the Nearest Neighbor Greedy Algorithm, starting from A (only), to find a Hamilton circuit. What is its total length?
Apply the Nearest Neighbor Greedy Algorithm, starting from D (only), to find a Hamilton circuit. What is its total length?
Apply the Cheapest Link Greedy Algorithm to find a Hamilton circuit. What is the length of this circuit?
The example in Problem 6.20 shows how the greedy algorithms are normally used. They are the best methods currently available to efficiently compute low weight Hamilton circuits when the Brute Force Algorithm is not feasible to use, as illustrated in Problem 6.9. However, there are instances where they can fail completely.
Construct a weighted graph with 4 vertices and some edges of equal weight such that both greedy algorithms can be used to obtain either a minimum weight Hamilton circuit or a maximum weight Hamilton circuit, depending on the choices made along the way.