Chapter 2: Business Efficiency Hamiltonian Circuit Visiting Vertices –In some graph theory problems, it is only necessary to visit specific locations (using.

Slides:



Advertisements
Similar presentations
Chapter 2: Business Efficiency Lesson Plan
Advertisements

Introduction to Graph Theory Instructor: Dr. Chaudhary Department of Computer Science Millersville University Reading Assignment Chapter 1.
Chapter 2: Business Efficiency Lesson Plan Business Efficiency  Visiting Vertices-Graph Theory Problem Hamiltonian Circuits  Vacation Planning Problem.
Chapter 7 Graph Theory 7.1 Modeling with graphs and finding Euler circuits. Learning Objectives: Know how to use graphs as models and how to determine.
Lecture 21 Paths and Circuits CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
BY: MIKE BASHAM, Math in Scheduling. The Bridges of Konigsberg.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley. All rights reserved.
1 Chapter 15.3 Hamilton Paths and Hamilton Circuits Objectives 1.Understand the definitions of Hamilton paths & Hamilton circuits. 2.Find the number of.
Chapter 4 sec. 2.  A famous and difficult problem to solve in graph theory.
1 Greedy Algorithms. 2 2 A short list of categories Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide.
A traveling salesman has customers in 5 cities which we will call A, B, C, D, and E. The salesman needs to travel to all 5 cities with his trip starting.
Chapter 2: Business Efficiency Lesson Plan Business Efficiency  Visiting Vertices-Graph Theory Problem Hamiltonian Circuits  Vacation Planning Problem.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley. All rights reserved.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Slide 14-1 Copyright © 2005 Pearson Education, Inc. SEVENTH EDITION and EXPANDED SEVENTH EDITION.
Chapter 12 Coping with the Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
SPANNING TREES Lecture 21 CS2110 – Spring
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 6 The Mathematics of Touring 6.1Hamilton Paths and Hamilton Circuits.
Graph Theory Topics to be covered:
Slide Copyright © 2009 Pearson Education, Inc. AND Active Learning Lecture Slides For use with Classroom Response Systems Chapter 14 Graph Theory.
Graph Theory Hamilton Paths and Hamilton Circuits.
Spring 2015 Mathematics in Management Science Network Problems Networks & Trees Minimum Networks Spanning Trees Minimum Spanning Trees.
1 Excursions in Modern Mathematics Sixth Edition Peter Tannenbaum.
© 2010 Pearson Prentice Hall. All rights reserved. 1 §15.3, Hamilton Paths and Circuits.
Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms.
Chapter 2: Business Efficiency Lesson Plan
Chapter 2: Business Efficiency Lesson Plan
Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 1 4 Graph Theory (Networks) The Mathematics of Relationships 4.
Minimum Spanning Trees Prof. Sin-Min Lee Dept. of Computer Science, San Jose State University.
6.4: The Brute-Force Algorithms
Chapter 3 Brute Force. A straightforward approach, usually based directly on the problem’s statement and definitions of the concepts involved Examples:
Chapter 2: Business Efficiency Lesson Plan Business Efficiency  Visiting Vertices-Graph Theory Problem Hamiltonian Circuits  Vacation Planning Problem.
Chapter 14 Section 4 - Slide 1 Copyright © 2009 Pearson Education, Inc. AND.
EXCURSIONS IN MODERN MATHEMATICS SIXTH EDITION Peter Tannenbaum 1.
Graphs A ‘Graph’ is a diagram that shows how things are connected together. It makes no attempt to draw actual paths or routes and scale is generally inconsequential.
Spring 2015 Mathematics in Management Science Network Problems Networks & Trees Minimum Networks Spanning Trees Minimum Spanning Trees.
Mathematics in Management Science
CIRCUITS, PATHS, AND SCHEDULES Euler and Königsberg.
EXCURSIONS IN MODERN MATHEMATICS SIXTH EDITION Peter Tannenbaum 1.
Graph Theory Hamilton Paths Hamilton Circuits and.
SPANNING TREES Lecture 20 CS2110 – Fall Spanning Trees  Definitions  Minimum spanning trees  3 greedy algorithms (incl. Kruskal’s & Prim’s)
AND.
I can describe the differences between Hamilton and Euler circuits and find efficient Hamilton circuits in graphs. Hamilton Circuits I can compare and.
Chapter 3 Brute Force Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 14 Section 3 - Slide 1 Copyright © 2009 Pearson Education, Inc. AND.
Unit 2 Hamiltonian Circuits. Hamiltonian Circuit: A tour that starts at a vertex of a graph and visits each vertex once and only once, returning to where.
Turn in HW and Classwork sheet from last class. You have 10 minutes to complete the warm- up. After the warm-up, we will finish our notes on algorithms.
Grade 11 AP Mathematics Graph Theory Definition: A graph, G, is a set of vertices v(G) = {v 1, v 2, v 3, …, v n } and edges e(G) = {v i v j where 1 ≤ i,
Mathematical modeling To describe or represent a real-world situation quantitatively, in mathematical language.
MAT 110 Workshop Created by Michael Brown, Haden McDonald & Myra Bentley for use by the Center for Academic Support.
Hamilton Paths and Hamilton Circuits
Excursions in Modern Mathematics Sixth Edition
D1 Discrete Mathematics
6.4: The Brute-Force Algorithms
Weighted Graphs and traveling Salesperson problem
Routing Through Networks - 1
Chapter 3 Brute Force Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
HAMILTONIAN CIRCUIT ALGORITHMS
Chapter 2: Business Efficiency Lesson Plan
Discrete Maths 9. Graphs Objective
Chapter 2: Business Efficiency Lesson Plan
* Hamiltonian Circuits introduction
The Travelling Salesperson problem
D1 Discrete Mathematics
Chapter 2: Business Efficiency Business Efficiency
Chapter 3 Brute Force Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Hamilton Paths and Hamilton Circuits
Euler circuit Theorem 1 If a graph G has an Eulerian path, then it must have exactly two odd vertices. Theorem 2 If a graph G has an Eulerian circuit,
Spanning Trees Lecture 20 CS2110 – Spring 2015.
Presentation transcript:

Chapter 2: Business Efficiency Hamiltonian Circuit Visiting Vertices –In some graph theory problems, it is only necessary to visit specific locations (using the travel routes, or streets available). –Problem: Find an efficient route along distinct edges of a graph that visits each vertex only once in a simple circuit. 1

Chapter 2: Business Efficiency Hamiltonian Circuit 2 Applications: Salesman visiting particular cities Delivering mail to drop-off boxes Route taken by a snowplow Pharmaceutical representative visiting doctors

Hamiltonian Circuit Suppose we change the “Bridges of Konigsberg” problem so that we visit each land mass exactly once. Does this make the problem easier to do? 3 L R K O YES!!

Chapter 2: Hamilton Circuits Outline/Learning Objectives To identify and model Hamilton circuit problems. To use the following algorithms to determine the optimal route for a Traveling Salesman Problem. –Nearest Neighbor and Sorted Edges Algorithms –Minimum-Cost Spanning Trees Kruskal’s Algorithm

(1805 – 1865) He was a renowned Irish mathematician and astronomer. He was a child prodigy. He could read English, Hebrew, Greek, and Latin by the time he was 4 yrs old. He became Professor of Astronomy at Trinity College in Dublin, Ireland when he was 23 yrs old. 5 Sir William Rowan Hamilton

Starting at vertex A, the tour can be written as ABDGIHFECA, or starting at E, it would be EFHIGDBACE. Hamiltonian Circuit: A path that starts and ends at the same vertex. Visits each vertex only once. A different circuit visiting each vertex once and only once would be CDBIGFEHAC (starting at vertex C).

-Circuits can start at any location. - Notice that we don’t care that we don’t use all the edges. -Use wiggly edges to show the circuit. -Unfortunately, there are no theorems that tell us whether or not a graph has a Hamilton Circuit. 7 Starting at vertex A, the tour can be written as ABDGIHFECA, or starting at E, it would be EFHIGDBACE. Hamiltonian Circuit: A different circuit visiting each vertex once and only once would be CDBIGFEHAC (starting at vertex C).

8 Hamiltonian Circuit vs. Euler Circuits Hamiltonian circuit – A path (shown by wiggly edges) that starts at a vertex of a graph and visits each vertex once and only once, returning to where it started. Euler circuit – A circuit that traverses each edge of a graph exactly once and starts and stops at the same vertex.

Similarities –Both forbid re-use. Hamiltonian didn’t reuse vertices. Euler didn’t reuse edges. Differences –Hamiltonian is a circuit of vertices. –Euler is a circuit of edges. –Euler graphs are easy to spot (connectedness and even valence). –Hamiltonian circuits are NOT as easy to determine upon inspection. 9 Hamiltonian Circuit vs. Euler Circuits

10 Hamiltonian Circuit vs. Euler Circuits Find both an Euler and Hamilton Circuit A B D G F E C Hamilton: one possible solution: AGFECDBA Euler: B and D have odd valences. Therefore, there is NO Euler Circuit.

What are the possible Hamilton Circuits for this graph? 11 A B D C One possible route: ABCDA or ADCBA Others: ABDCA or ACDBA ACBDA or ADBCA only 3 Notice that there are “mirror images” so then there are really only 3 different Hamilton circuits.

What are the possible Hamilton Circuits for this graph if we start at A? 12 A B D C ABCDA or ADCBA ABDCA or ACDBA ACBDA or ADBCA When we start at A how many ways can we travel: If we choose B, how many ways can we travel: If we choose D, how many ways can we travel: This means that we can have 3 x 2 x 1 possible different combinations. This can be written as 3! How does 3 relate to the number of vertices? 3! = 6, but half were mirror images so 3!/2 = 3 would be the correct amount of unique Hamilton circuits. 3 (B, D, C) 2 (D, C) 1 (C) One less than

Unique Hamilton Circuits 13 Principle of Counting for Hamiltonian Circuits –For a complete graph of n vertices, there are (n - 1)! possible routes. –Half of these routes are repeats, the result is: Possible unique Hamiltonian circuits are (n - 1)! / 2 Complete graph – A graph in which every pair of vertices is joined by an edge. Fundamental Principle of Counting If there are a ways of choosing one thing, b ways of choosing a second after the first is chosen, c ways of choosing a third after the second is chosen…, and so on…, and z ways of choosing the last item after the earlier choices, then the total number of choice patterns is a × b × c × … × z. Example: Jack has 9 shirts and 4 pairs of pants. He can wear 9 × 4 = 36 shirt-pant outfits.

How many unique Hamilton circuits are there and name one. 14 D A E C B 5 vertices so there are 4! Hamilton circuits. 4! = 24 circuits 24/2 = 12 unique circuits (Be happy. I will only ask you to find one!) Example: ABCDEA

Weighted Graphs Vacation–Planning Problem  What would be the best route to take if you want to visit all 4 cities?  Hamiltonian circuit concept is used to find the best route (optimal route) that minimizes the total distance traveled to visit friends in different cities. (assume less mileage  less gas  minimizes costs) Road mileage between four cities 15 Hamiltonian circuit with weighted edges  Edges of the graph are given weights, or in this case mileage or distance between cities.  As you travel from vertex to vertex, add the numbers (mileage in this case).  Each Hamiltonian circuit will produce a particular sum.

WWeighted graph – has numbers assigned to an edge that can be thought of as cost, distance, or time. OOptimal solution – when a problem has various solutions and you pick the best solution for you. AAlgorithm – A step-by-step description of how to solve a problem. Heuristic Algorithm – A “fast” method that doesn’t guarantee an optimal answer. Definitions

17 Weighted Graphs where the number of vertices in a complete graph are very large. Difficult to solve Hamiltonian circuits. This problem originated from a salesman determining his trip that minimizes costs (less mileage) as he visits the cities in a sales territory, starting and ending the trip in the same city. Many applications today: bus schedules mail drop-offs to post offices Candy machine coin pick-up routes UPS Running phone lines or cable Water lines Traveling Salesman Problem (TSP)

18 How can the TSP be solved? Computer program can find optimal route (not always practical). Exhaustive search called Brute Force Algorithm (Trees can be used) Heuristic methods can be used to find a “fast” answer, but does not guarantee that it is always the optimal answer. – Nearest Neighbor Algorithm (NNA) – Sorted Edges Algorithm (also known as “Cheapest Link”) –Kruskal’s Algorithm (Minimum Spanning Trees) Traveling Salesman Problem (TSP)

19 1)Brute Force Algorithm – optimal algorithm that always works but inefficient. Creates a Hamilton Circuit. 2) Nearest-Neighbor Algorithm (NNA) – not optimal but efficient. Creates a Hamilton Circuit. 3) Sorted-Edges Algorithm - not optimal but efficient. Creates a Hamilton Circuit. 4) Kruskal’s Algorithm and Minimum Cost Spanning Trees - not optimal but efficient. Does NOT create a Hamilton Circuit. TSP Strategies for complete graphs

TSP Strategy Brute Force Algorithm Algorithm (step-by-step process) for solving this airplane route problem 20 1.Generate all possible Hamiltonian tours (paths) using a table. 2.Add up the distances on the edges of each tour. 3.Choose the tour of minimum distance. CL C M S

TSP Strategy Brute Force Algorithm Use the Brute Force Algorithm to determine the optimal Hamilton Circuit. 21 Hamilton CircuitWeightsTotal Weight C,S,M,CL,C (or C,CL,M,S,C) C,M,CL,S,C (or C,S,CL,M,C) C,M,S,CL,C (or C,CL,S,M,C) ,985 2,040 1,877

TSP Strategy Brute Force Algorithm The optimal Hamilton Circuit is: C,M,S,CL,C Chicago, Minn., St. Louis, Cleveland, and back to Chicago. 22

TSP Strategy Brute Force Algorithm and Trees 23 This method begins by selecting a starting vertex, say Chicago, and making a tree- diagram showing the next possible locations. In this example, the method of trees generated six different paths, all starting and ending with Chicago. However, only three are unique circuits. At the end of each path put total weight. Instead of creating a table, you create a tree.

TSP Strategy Brute Force Algorithm and Trees Definition: Tree – connected graph with NO circuits.

Use the Brute Force Algorithm to determine the optimal Hamilton Circuit. 25 D A E B C How many Hamilton Circuits are there? How many are unique Hamilton Circuits? (5-1)! = 4! = 24 24/2 = 12

Use the Brute Force Algorithm to determine the optimal Hamilton Circuit. 26 Hamilton Circuit Weights Total weight Hamilton Circuit Weights Total weight ABCDEA ACEBDA ACEDBA ACDEBA ACDBEA ACBEDA ACBDEA ABECDA ABEDCA ABDECA ABDCEA ABCEDA ADBCEA ADECBA ADEBCA ADCBEA ADCEBA ADBECA AEBCDA AEDCBA AEDBCA AECDBA AECBDA AEBDCA

Use the Tree method to determine the optimal Hamilton Circuit. A BCDE BCEBCD CDEBDE D C B D BC CE B E BCD E B E B DE C E CDD E D E C DCE DE B DB ECEBCBCDDBCB A A A A AAAAA A AAAAAAAAAAAA AA

TSP Strategy Nearest Neighbor Algorithm (NNA) 28 NNA starting at vertex A Hamiltonian Circuit: A-B-C-E-D-A 1)Pick a “home” city (or vertex). 2)Travel from vertex to vertex by always choosing the next vertex that can be reached quickest (least miles), that has not already been visited. 3)When all vertices have been visited, the tour returns home. NNA starting at vertex B Hamiltonian Circuit: B-C-A-D-E-B

Use the NNA to determine the optimal Hamilton Circuit. 29 D A E B C Starting vertex Nearest Neighbor Nearest Neighbor Nearest Neighbor Nearest Neighbor Back to start Total AA DCEB

TSP Strategy Sorted Edges Algorithm 1)Start by sorting, or arranging, the edges in order of increasing weight (smallest to largest mileage between cities). 2)Choose an edge with lowest weight a)That will NOT result in three edges meeting at a vertex b)That will NOT close up a path that doesn’t include all vertices 3)Repeat #2 until all vertices are used. 4)From last vertex, return to start 30 D A E B C

TSP Strategy Sorted Edges Algorithm 31 D A E B C )Arrange edges in order low to high: BE 165 AD 185 BD 200 ED 205 AE 302 BC 305 AB 320 EC 340 AC 360 DC 500

D A E B C BE 165 AD 185 BD 200 ED 205 AE 302 BC 305 AB 320 EC 340 AC 360 DC 500 Total: circuit 3 edges Not needed 1250 Hamilton circuit: ADBECA or ACEBDA Step 2) Choose an edge with lowest weight That will NOT result in three edges meeting at a vertex That will NOT close up a path that doesn’t include all vertices Step 3) Repeat #2 until all vertices are used. Step 4) From last vertex, return to start

Recall the Tree method to determine the optimal Hamilton Circuit. A BCDE BCEBCD CDEBDE D C B D BC CE B E BCD E B E B DE C E CDD E D E C DCE DE B DB ECEBCBCDDBCB A A A A AAAAA A AAAAAAAAAAAA AA

Definition: Spanning Tree – is a subgraph that connects all vertices and has NO circuits. Therefore, you don’t go back to A at the end. Each branch of a tree is a “spanning tree”

TSP Strategy - Spanning Trees 35 D A E B C Spanning trees look more like this: B C E D A Spanning trees don’t really look like this though.

TSP Strategy - Spanning Trees 36 D A E B C D A E B C Original:Example 1) D A E B C Example 2)

Minimum-Cost Spanning Trees and Kruskal's Algorithm 37 Goal of minimum-cost spanning tree: Create a tree that links all the vertices together and achieves the lowest cost to create. The cost of the tree is the sum of the weights on the edges.

Minimum-Cost Spanning Trees and Kruskal's Algorithm 38 Kruskal’s Algorithm — Developed by Joseph Kruskal (AT&T research). –Add links in order of cheapest cost according to the rules: No circuit is created (no loops). –If a circuit (or loop) is created by adding the next largest link, eliminate this largest (most expensive link)—it is not needed. Every vertex must be included in the final tree.

TSP Strategy Minimum-Cost Spanning Trees 39 D A E B C Kruskal's Algorithm 1) On every step mark the cheapest unmarked edge. - See that the marked edges do not form circuits (loops). 2) Repeat while possible until all vertices are connected. 302 Total distance: 855 miles

Minimum-Cost Spanning Trees and Kruskal's Algorithm 40 The diagram shows the cost to build the connection from each vertex to all other vertices (connected graph). Costs (in millions of dollars) of installing Pictaphone service among five cities The cost of redirecting the signal may be small compared to adding another link. Example: What is the cost to construct a Pictaphone service (telephone service with video image of the callers) among five cities? Total cost: $2.55 million