Sec 2. Euler Circuits, cont. Which are cut edges? E D A v Euler Circuits traverse each edge of a connected graph exactly once. v Recall that all vertices must have even degree in order for an Euler Circuit to exist. F C B E D A v Fleury's Algorithm is a method for nding an Euler Circuit. H G Graph I. F v A cut edge in a graph is an edge whose removal disconnects a component of the graph. C B H G Graph II. © 2005–09, N. Van Cleave 1 Fleury's Algorithm © 2005–09, N. Van Cleave 2 Apply Fleury's Algorithm to the following graphs: B A C D 1. Pick a vertex and write it down as the start of the Euler Circuit. E F G 2. Pick any edge incident to this vertex, traverse it to the other end point, add that end point to the Circuit, then erase the edge. Graph I. 3. Choose any edge from this new vertex, subject to the condition that you do not choose a cut edge unless there is no other option. A F D 4. Traverse this edge to the other vertex, add that vertex to the Circuit, then erase the edge. 5. Repeat from Step 3 until all the edges have been erased and you're back to the Start vertex. © 2005–09, N. Van Cleave 3 B C G E Graph II. If we start with a connected graph in which all vertices have even degree, then Fleury's Algorithm will always produce an Euler circuit. © 2005–09, N. Van Cleave 4 Section 3. Hamilton Circuits E A A Hamilton Circuit in a graph is a circuit that visits each vertex exactly once, returning to the starting vertex to complete the circuit. D B Which of the given paths are Hamilton Circuits? C a) A − B − C − D − E − A b) B − E − C − D − A − B A c) E − B − A − D − A − D − C − E Graph II. B E C D B A a) A − E − C − D − E − B − A b) A − E − C − D − B − A c) D − B − E − A − B D E d) E − D − C − B − E Graph III. F A - B - E - D - C - F - A A - B - C - D - E - F - C - E - B - F - A B - C - D - E - F - B Graph I. © 2005–09, N. Van Cleave C 5 © 2005–09, N. Van Cleave 6 Find a Hamilton Circuit in the following graphs (if one exists): A F A E A D F H A C E B F E B D C C Graph III. Graph II. © 2005–09, N. Van Cleave 7 Graph IV. © 2005–09, N. Van Cleave 8 C A B D E A M C A C B D E B D Graph I. C B G D L F K G B H G J I Graph V. Graph VI. © 2005–09, N. Van Cleave O K P H N L Graph VII. 9 E J M E F D Q Graph VIII. © 2005–09, N. Van Cleave 10 Hamilton Circuits for Complete Graphs Tree Diagrams Any complete graph with three or more vertices has a Hamilton Circuit. Tree Diagrams are a convenient strategy for inspecting all possible combinations when we are given multiple choices to make. A In Hamilton Circuits, we can begin with any vertex in the graph, then choose among those which are adjacent to it. . . B F In the graph below, note how the tree diagram lists all the possible circuits in the graph: 3! (three factorial or 1 2 3) of them. C A E D When Hamilton Circuits Are the Same: Hamilton circuits that differ only in their starting points will be considered to be the same circuit. A D A-B-C-D-E-F-A is essentially the same as B-C-D-E-F-A-B, since the vertices are visited in the same order. © 2005–09, N. Van Cleave B B 11 © 2005–09, N. Van Cleave C C D C D A D C A B D A D B A C B B A A C 12 Number of Hamilton Circuits in a Complete Graph How many circuits would we nd in the following graph? A B F A complete graph with n vertices has (n 1)! Hamilton circuits. Recall: a weighted graph is one in which weights or costs are assigned to the graph's edges. C The total weight of a circuit in a weighted graph is the sum of the weights of the edges in the circuit. E D How many circuits would a complete graph over 10 vertices, a K10, have? © 2005–09, N. Van Cleave 13 Brute Force Minimum Hamilton Circuit Algorithm A Minimum Hamilton Circuit in a weighted graph is a Hamilton Circuit with smallest possible total weight. © 2005–09, N. Van Cleave 14 Find a minimum Hamilton Circuit for the complete, weighted graph shown here: 3 A 1 1. Choose a starting vertex 1 2. List all the Hamilton Circuits with that starting vertex D 6 3 Possible Circuits 3. Find the total weight of each circuit B 4 C Total circuit weight 4. Choose a Hamilton Circuit with the smallest total weight © 2005–09, N. Van Cleave 15 © 2005–09, N. Van Cleave 16 Nearest Neighbor Algorithm v This brute force method is time consuming. 1. Choose a starting vertex for the circuit; call it vertex A. v As the number of vertices grows, the time it takes to check all possible Hamilton Circuits grows very fast! v Thus, we're interested in other methods for nding a solution — in this case, just a reasonably good solution most of the time. v This type of algorithm is called an approximation algorithm. 2. Check all edges incident to A, and choose the one that has smallest weight; proceed along this edge to the next vertex. 3. At each vertex you reach, check the edges from there to vertices not yet visited. Choose one with smallest weight. Proceed along this edge to the next vertex. 4. Repeat Step 3 until all vertices have been visited. v The following algorithm nds an approximate solution to the Minimum Hamilton Circuit problem. 5. Return to the starting vertex A. © 2005–09, N. Van Cleave © 2005–09, N. Van Cleave 17 18 Apply this algorithm to the following graph. difference at what vertex we begin? Does it make any Find a Hamilton Circuit starting at vertex A in the following graph: A 8 B 13 9 C Q O 5 7 D Circuit Using Nearest Neighbor P I R E Total Weight J S T C N K M A B C D E © 2005–09, N. Van Cleave H G E 8 10 B F 20 3 8 Starting Vertex A L D 19 © 2005–09, N. Van Cleave 20
© Copyright 2026 Paperzz