1 / 18

Lecture 21 Paths and Circuits

Lecture 21 Paths and Circuits. CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine. Lecture Introduction. Reading Rosen Section 10.1 Application of Graph Theory Euler Paths and Circuits Hamiltonian Paths and Circuits Traveling Salesman Problem. Definitions.

gavin-chan
Télécharger la présentation

Lecture 21 Paths and 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. Lecture 21Paths and Circuits CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine

  2. Lecture Introduction • Reading • Rosen Section 10.1 • Application of Graph Theory • Euler Paths and Circuits • Hamiltonian Paths and Circuits • Traveling Salesman Problem CSCI 1900

  3. Definitions • Given a graph G and vertices v and w in G • A walk is a finite alternating sequence of vertices and edges of G • A path from v to w is a walk that does not contain repeated edges • A simple path from v to w is path that does not contain a repeated vertex • A closed walk is a walk that starts and ends at the same vertex • A circuit is a closed walk that does not contain a repeated edge • A simple circuit is a circuit that has no repeated vertices except the first and the last CSCI 1900

  4. A walk v2e2v3e6v5e5v2e2v3e3v4 A path v2e2v3e6v5e5v2e1v1 A simple path v3e6v5e5v2e1v1 A circuit v2e5v5e6v3e3v4e4v1e7v3e2v2 A simple circuit v2e5v5e6v3e7v1e1v2 Consider the graph v1 v2 e1 e5 e4 e2 v5 e7 e6 e3 v4 v3 Example: Walks, Paths, Circuits CSCI 1900

  5. Euler Circuits • Given a graph G, an Euler circuit for G is a sequence of adjacent vertices and edges in G that • Starts and ends at the same vertex, • Uses every vertex of G at least once, and • Uses every edge of G exactly once CSCI 1900

  6. Theorems on Euler Circuits • The following theorem is quoted without proof: • If a graph has an Euler Circuit, then every vertex is of even degree • The Contrapositive • If some vertex of a graph is of odd degree, then the graph does not have a Euler Circuit CSCI 1900

  7. Does the graph have an Euler Circuit? Why or why not? If not, how many edges must be added or removed to admit the existence of an Euler Circuit? Consider the prior graph v1 v2 e1 e5 e4 e2 v5 e7 e6 e3 v4 v3 Example: Euler Circuit CSCI 1900

  8. Bridges of Königsberg Problem The town of Königsberg was built at the confluence of two branches of the Pregel river. The Pregel river divides the land into four land masses. These land masses are connected by seven bridges. The citizens spent many a pleasant Sunday afternoon trying to find a walk that would start on one of the land masses, cross all the bridges exactly once and end on the starting land mass. CSCI 1900

  9. Map of Königsberg Source: http://commons.wikimedia.org/wiki/File:Konigsberg_bridges.png CSCI 1900

  10. In 1736, Leonhard Euler resolved the problem with reasoning equivalent to the two previously quoted theorem Draw the graph corresponding to the map of Konigsberg Determine the degree of the vertices of your graph By applying the theorem, show that no circuit is possible The Solution CSCI 1900

  11. Hamiltonian Circuits • A related circuit is the Hamiltonian circuit • Given a graph G, a Hamiltonian circuit, H of G, is a sequence of adjacent vertices and distinct edges, in which every vertex of G appears exactly once in H CSCI 1900

  12. Theorem on Hamilton Circuits • If a graph G has a Hamiltonian circuit, then G has a subgraph H with the following properties • H contains every vertex in G • H is connected • H has the same number of edges as vertices • Every vertex of H has degree 2 CSCI 1900

  13. Given a set of cities (represented by vertices) that are connected by a set of roads (represented by edges) Suppose that a salesman must travel to each of the cities exactly once, starting and ending at one of the cities What route, driven over exiting roads, minimizes the distance that the salesman must drive? Traveling Salesman Problem CSCI 1900

  14. Given the above weighted graph, what is the minimum distance the salesman must travel, starting and ending in city A? A B 30 30 25 50 35 40 D C Example: Traveling Salesman CSCI 1900

  15. Solution: Traveling Salesman • List all Hamiltonian Circuits • Calculate the total distance for each circuit • Select the minimum circuit CSCI 1900

  16. Traveling Salesman Problem Exact solution? Only known general solution is by enumeration of all possible routes For a complete graph with n nodes Since we must start and end with one of the nodes,we need the number of permutations of (n-1) vertices, taken (n-1) at a time n-1Pn-1 = (n-1)! Hamiltonian circuits For n = 10 number of circuits =362,880For n = 50 number of circuits > 1 x 1064 CSCI 1900 Lecture 21 - 16

  17. Traveling Salesman (cont) There exist approximate solutions that yield a “good” solution, but not the best solution “Good” means that the approximate solution will have a smaller total distance than most of the Hamiltonian circuits CSCI 1900 Lecture 21 - 17

  18. Key Concepts Summary Walks, paths, and circuits Euler Circuits Application: Seven Bridges of Königsberg Hamiltonian Circuits Application: Traveling Salesman problem Reading for next time No further readings CSCI 1900 Lecture 21 - 18

More Related