160 likes | 425 Views
Aim: How does a Hamilton path and circuit differ from Euler’s path and circuit?. Do Now:. How does finding an efficient way to plow the streets of NY differ from finding an efficient way for UPS to deliver packages throughout the city?. Hamilton Paths & Circuits.
E N D
Aim: How does a Hamilton path and circuit differ from Euler’s path and circuit? Do Now: How does finding an efficient way to plow the streets of NY differ from finding an efficient way for UPS to deliver packages throughout the city?
Hamilton Paths & Circuits Hamilton path – a path that passes through each vertex of a graph exactly once. Hamilton circuit – a path that passes through each vertex of a graph exactly once and begins and ends at the same vertex. Find a Hamilton path. A, B, C, D, E Find a Hamilton circuit A, B, C, D, E, A
Complete/Incomplete Graphs Complete graph – a graph that has an edge between each pair of vertices. Every complete graph with three or more vertices has a Hamilton circuit. incomplete graph missing
Model Problem Find a Hamilton path that begins at vertex E for the graph below. Find a Hamilton circuit that begins at vertex E for the graph below.
Number of Hamilton Circuits Find as many Hamilton circuits as possible. A, B, C, D, A A, B, D, C, A four vertices – 6 circuits permutations A, C, B, D, A A, C, D, B, A A, D, B, C, A A, D, C, B, A
Number of Hamilton Circuits The number of Hamilton circuits in a complete graph with n vertices is (n – 1)!. • How many Hamilton circuits in a complete • graph with • four vertices • b) five vertices • c) eight vertices n = 4 (4 – 1)! = 6 n = 5 (5 – 1)! = 24 n = 8 (8 – 1)! = 5040
The Traveling Saleperson A sales director who lives in city A is required to travel to regional offices in cities B, C, and D. There are no restrictions on the order of the visits but cheaper is better and he/she must get back home. one-way fares weighted graph What is the cost if circuit A, B, D, C, A is traveled? 190 + 155 + 179 + 124 = $648
Optimal Hamilton Circuit Optimal Hamilton Circuit – in a complete weighted graph, where the sum of the weight of the edges is a minimum. Option One – Brute Force Method • Model the problem with a complete, • weighted graph. • Make a list of all possible Hamilton circuits. • Determine the sum of the weights of the • edges for each of these circuits. • 4. The Hamilton circuit with the minimum • sum of weights is the optimal solution.
Model Problem Find the optimal solutions for our salesperson. one-way fares weighted graph
Model Problem Find the optimal solutions for the weighted graph below.
Optimal Solution – Option Two When number of vertices (options) get large, brute force method is unmanageable. Option Two – Nearest Neighbor Method • Model the problem with a complete, weighted graph. • Identify the vertex that serves as the starting point. • From the starting point, choose the edge with the smallest weigh. Move along this edge to the 2nd vertex. • From the 2nd vertex, choose the edge with the smallest weight that does not lead to a vertex already visited. • Continue building the circuit, one vertex at the time. • From the last vertex, return to the starting point. This method approximates the lowest cost
Model Problem A sales director who lives in city A is required to fly to regional offices in cities B, C, D, and E. The weighted graph showing the one-way airfares is given below. Approximate the lowest cost. A, C 114 C, E 115 E, D 194 D, B 145 B, A 180 A, C, E, D, B, A $748 • Model the problem with a complete, weighted graph. • Identify the vertex that serves as the starting point. • From the starting point, choose the edge with the smallest weigh. Move along this edge to the 2nd vertex. • From the 2nd vertex, choose the edge with the smallest weight that does not lead to a vertex already visited. • Continue building the circuit, one vertex at the time. • From the last vertex, return to the starting point.
Model Problem Use the Nearest Neighbor Method to approximate the optimal solution for the complete, weighted graph below.