1 / 36

Euler Paths & Circuits Hamilton Paths & Circuits

Euler Paths & Circuits Hamilton Paths & Circuits. Thinking Mathematically , Sections 15.2 & 15.3. Euler Paths and Euler Circuits. Section 15.2. Review from last lesson. adjacent vertices – vertices that are connected directly and thus share at least one edge

iona
Télécharger la présentation

Euler Paths & Circuits Hamilton Paths & Circuits

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Euler Paths & CircuitsHamilton Paths & Circuits Thinking Mathematically, Sections 15.2 & 15.3

  2. Euler Pathsand Euler Circuits Section 15.2

  3. Review from last lesson • adjacent vertices – vertices that are connected directly and thus share at least one edge • path – a sequence of adjacent vertices and the edges connecting them, denoted by a list of vertices in order • circuit – a path that begins and ends at the same vertex path: A,B,F,G,H,M circuit: A,B,F,G,L,K,J,E,A NOTE 1: An edge can be part of a path only once. NOTE 2: A path does not have to traverse the entire graph.

  4. Definitions • Euler path – a path that travels through every edge of a graph once and only once. • Euler circuit – a circuit that travels through every edge of a graph once and only once. OR – a Euler path that begins and ends at the same vertex. So, if the graph is traversable then it has a Euler path! Every Euler circuit is an Euler path . . . but not every Euler path is an Euler circuit!

  5. Euler’s Rules of Traversability NOTE: Rules are only for connected graphs. 1. A graph with all even vertices is traversable. One can start at any vertex and end at same vertex. 2. A graph with two odd vertices is traversable. One must start at one odd vertex and end at the other odd vertex. 3. A graph with more than two odd vertices is NOT traversable. Euler Circuit Euler Path Neither

  6. ExampleFind the Euler path or circuit, if any. 2. A graph with two odd vertices is traversable. One must start at one odd vertex and end at the other odd vertex. Even (2) Euler Path Even (4) Even (4) Odd (3) Odd (3)

  7. ExampleFind the Euler path or circuit, if any. 2. A graph with two odd vertices is traversable. One must start at one odd vertex and end at the other odd vertex. A Euler Path E B D C Euler Path: C,B,A,E,B Euler Path: C,B,A,E,B,D Euler Path: C,B,A,E,B,D,E,C,D Euler Path: C Euler Path: C,B,A Euler Path: C,B Euler Path: C,B,A,E Euler Path: C,B,A,E,B,D,E Euler Path: C,B,A,E,B,D,E,C Euler Path:

  8. ExampleFind the Euler path or circuit, if any. 2. A graph with two odd vertices is traversable. One must start at one odd vertex and end at the other odd vertex. 2 3 Euler Path 4 7 5 6 1 8 Number the Euler Path at each step.

  9. ExampleFind the Euler path or circuit, if any. Even (4) Even (2) Even (2) Euler Circuit Even (4) Even (4) 1. A graph with all even vertices is traversable. One can start at any vertex and end at same vertex. Even (2) Even (2)

  10. ExampleFind the Euler path or circuit, if any. C D B Euler Circuit E G A 1. A graph with all even vertices is traversable. One can start at any vertex and end at same vertex. F Euler Circuit: A,B,C,G,E,C Euler Circuit: Euler Circuit: A,B,C,G,E Euler Circuit: A,B,C,G,E,C,D Euler Circuit: A,B,C,G,E,C,D,E,F,G,A Euler Circuit: A,B,C,G,E,C,D,E,F Euler Circuit: A,B,C,G,E,C,D,E,F,G Euler Circuit: A,B,C,G,E,C,D,E Euler Circuit: A Euler Circuit: A,B,C,G Euler Circuit: A,B,C Euler Circuit: A,B

  11. ExampleFind the Euler path or circuit, if any. 6 2 5 3 7 1 Euler Circuit 4 10 1. A graph with all even vertices is traversable. One can start at any vertex and end at same vertex. 8 9 Number the Euler Circuit at each step.

  12. ExampleFind the Euler path or circuit, if any. 3. A graph with more than two odd vertices is NOT traversable. Even (4) Odd (3) Odd (3) Neither Odd (3) Odd (3)

  13. ExampleFind the Euler path or circuit, if any. 1 14 2 10 13 9 3 11 Euler Circuit 7 8 12 4 6 5 Number the Euler Circuit at each step.

  14. What if the Euler path or circuit is not easy to find? ExampleFind the Euler path or circuit, if any. Euler Path: B, L, D, O, L, O, D, K, O, B, K

  15. Review from last lesson • connected graph – a graph in which there is at least one path connecting any two vertices • disconnected graph – a graph in which there is no path connecting any two vertices • bridge – an edge that, if removed, would make a connected graph into a disconnected graph disconnected graph edge BG is a bridge

  16. How do we find the Euler path or Euler circuit? An algorithm is a step-by-step procedure. Fleury’s Algorithm • Check that the graph is connected. • Check that the graph is traversable using Euler’s Rules. • Choose a starting point based on Euler’s Rules. • After each edge is traveled over, erase it to create a reduced graph. You may want to show the erased edge as a dotted line. • When you have a choice between two edges, never take the bridge of a reduced graph. Travel over a bridge only when there is no other alternative. • Continue until you get to the appropriate vertex and the entire graph has been traversed.

  17. ExampleFind the Euler path or circuit, if any. YES Erase (make dotted) and number the edge that is traveled over. YES If you have the choice between two edges, never take the bridge. ANYWHERE Is the graph traversable? If you have the choice between two edges, never take the bridge. If you have the choice between two edges, never take the bridge. Erase (make dotted) and number the edge that is traveled over. Erase (make dotted) and number the edge that is traveled over. The entire graph has now been traversed. Erase (make dotted) and number the edge that is traveled over. If you have the choice between two edges, never take the bridge. Erase (make dotted) and number the edge that is traveled over. Is the graph connected? Where do we start? If you have the choice between two edges, never take the bridge. If you have the choice between two edges, never take the bridge. If you have the choice between two edges, never take the bridge. Erase (make dotted) and number the edge that is traveled over. If you have the choice between two edges, never take the bridge. Erase (make dotted) and number the edge that is traveled over. If you have the choice between two edges, never take the bridge. Erase (make dotted) and number the edge that is traveled over. Erase (make dotted) and number the edge that is traveled over. # 3 # 6 # 2 # 4 DONE! # 1 # 7 # 8 # 9 # 5 CA is bridge – don’t cross it. The others are not bridges. Go C to F. None are a bridge. Go D to C. There is no choice. Go F to E. There is no choice. Go D to B. Neither is a bridge. Go A to D There is no choice. Go B to F. There is no choice. Go C to A. FE is bridge – don’t cross it. The others are not bridges. Go F to D. There is no choice. Go E to C. 7 If you have more than one choice that is not a bridge, take either. BOTH WILL WORK to find different Euler paths or circuits. 3 8 4 2 6 1 5 9

  18. Hamilton Pathsand Hamilton Circuits Section 15.3

  19. Euler paths and circuits cover every edge of a graph. These are useful in optimizing routes for applications like garbage collection, where each street (edge) only needs to be traversed once but a particular intersection (vertex) may be crossed more than once. What about optimizing routes for applications like FedEx or UPS in package delivery? For these applications, we need to go to every house that has a delivery (vertices) but need not necessarily traverse every street (edge). For this, we need to examine Hamilton paths and circuits.

  20. Definitions • Hamilton path – a path that travels through every vertex of a graph one and only once. • Hamilton circuit – a Hamilton path that begins and ends at the same vertex and passes through all other vertices exactly once. This is not the same as being traversable. In fact, every edge does not even have to be crossed. NOTE: Euler’s Rules of Traversability do not help determine if there is a Hamilton path or circuit; those rules only apply to Euler paths and circuits. There is no connection between the Hamilton and Euler paths and circuits. In fact, a graph may have either one of these types, both types, or neither type.

  21. Just as with the Euler type, if there is a Hamilton circuit there must be a Hamilton path. ExampleExamine the graph below. Is there a Euler path or circuit? No, there is neither. 3. A graph with more than two odd vertices is NOT traversable. Is there a Hamilton path or circuit? Let’s try… Yes, there is a Hamilton path. and a Hamilton circuit.

  22. ExampleExamine the graph below. Is there a Hamilton path or circuit? Let’s try… Yes, there is a Hamilton path. but NO Hamilton circuit. Notice that all the vertices are even. Thus the graph has an Euler path and an Euler circuit.

  23. Definition • Complete graph – a graph that has an edge between each pair of its vertices NOTE: This is not the same as a connected graph. In a connected graph, all the vertices connect through some path which may travel over several edges. In a complete graph, there is a direct line, or edge, between each pair of vertices. Complete Graph Rule Every complete graph with 3 or more vertices has a Hamilton circuit. Complete Graph Rule Every complete graph with 3 or more vertices has a Hamilton circuit. (Thus it also has a Hamilton path.) Complete Graph Rule Every complete graph with 3 or more vertices has a Hamilton circuit. (Thus it also has a Hamilton path.) NOTE: If the graph is not complete, it may still have a Hamilton path or circuit but there doesn’t have to be one.

  24. ExampleThese are complete graphs:

  25. ExampleThese are complete graphs: These are not complete graphs:

  26. ExampleFind a Hamilton circuit: One possibility: A, B, C, D, E, A A E B What about finding a different one? B, C, D, E, A, B ? D C B, C, D, E, A, B is the SAME CIRCUIT! There are actually (n-1)! circuits in a complete graph with n vertices. To avoid duplication when listing them, the book always starts with “A” only. Here, there are 5 vertices, so there are (5-1)! = 4! = 4321 = 120 different Hamilton circuits for this complete graph!

  27. ExampleFind a Hamilton circuit: One possibility: A, B, C, D, E, A A E B What about finding a different one? A, C, E, B, D, A D C Here, there are 5 vertices, so there are 5! = 54321 = 120 different Hamilton circuits for this complete graph!

  28. Definition • Weighted graph – a complete graph whose edges have numbers, or weights, attached to them The “Traveling Salesman Problem” is a famous example of using a weighted graph to solve a problem.

  29. ExampleA sales director lives in City A and must fly to the regional offices in B, C, and D. There are direct flights between each pair of cities. He will return home at the end of the business trip. The chart below shows the airfares for all possible flights. HAMILTON CIRCUIT COMPLETE GRAPH

  30. Need a weighted graph. ExampleA sales director lives in City A and must fly to the regional offices in B, C, and D. There are direct flights between each pair of cities. He will return home at the end of the business trip. The chart below shows the airfares for all possible flights. A B D C How can the visits be scheduled in the cheapest possible way?

  31. ExampleA sales director lives in City A and must fly to the regional offices in B, C, and D. There are direct flights between each pair of cities. He will return home at the end of the business trip. The chart below shows the airfares for all possible flights. 190 A B 124 126 157 155 D C How can the visits be scheduled in the cheapest possible way? 179

  32. List all circuits. ExampleA sales director lives in City A and must fly to the regional offices in B, C, and D. There are direct flights between each pair of cities. He will return home at the end of the business trip. The chart below shows the airfares for all possible flights. Example 190 A B 124 126 157 155 D C How can the visits be scheduled in the cheapest possible way? 179

  33. List all circuits. Find total weights. Notice these are reversed. Example = 652 = 190 A, B, C, D, A + 126 + 179 + 157 = 190 + 155 + 179 + 124 = 648 A, B, D, C, A = 124 + 126 + 155 + 157 = 562 A, C, B, D, A = 124 + 179 + 155 + 190 = 648 A, C, D, B, A = 157 + 155 + 126 + 124 = 562 A, D, B, C, A = 157 + 179 + 126 + 190 = 652 A, D, C, B, A 190 A B For $ 562 can travel either: A, C, B, D, A A, D, B, C, A 124 126 157 Brute Force Method… calculate every possibility and see which is best. 155 D C How can the visits be scheduled in the cheapest possible way? 179

  34. Example Another way to find the correct route… NOTE: The Nearest Neighbor Method only approximates the smallest total weight. A D D can only return to A. B can only move to D. A can move to B, C, or D. C can move to B or D. 190 A B C B Which has smallest weight? Which has smallest weight? 124 126 157 155 D C 179 + 155 + 157 = 562 124 + 126 Nearest Neighbor Method From the starting point, choose the edge with the smallest weight. Continue choosing the edge with the smallest weight without going back to a previous vertex.

  35. Example Use the Nearest Neighbor Method to approximate the solution to the weighted graph below. Optimal solution is A, E, C, B, D, A (or its reverse) for $651. A 180 128 114 195 E B 147 145 116 194 115 A C E D B A 114 + 115 + 194 + 145 + 180 169 D C = 748

  36. Homework From the Cow book 10.7 pg 549 # 1 – 6 all 15.1 pg 786 # 1 – 47 odd 15.2 pg 796 # 1 – 39 odd 15.3 pg 808 # 1 – 7 odd, 9 – 13 odd part a only, 19 – 33 odd

More Related