HAMILTONIAN CIRCUIT ALGORITHMS

Slides:



Advertisements
Similar presentations
Introduction to Graph Theory Instructor: Dr. Chaudhary Department of Computer Science Millersville University Reading Assignment Chapter 1.
Advertisements

3.3 Spanning Trees Tucker, Applied Combinatorics, Section 3.3, by Patti Bodkin and Tamsen Hunter.
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.
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 9: Graphs Basic Concepts
The Travelling Salesman Algorithm A Salesman has to visit lots of different stores and return to the starting base On a graph this means visiting every.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley. All rights reserved.
Slide 14-1 Copyright © 2005 Pearson Education, Inc. SEVENTH EDITION and EXPANDED SEVENTH EDITION.
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 6 The Mathematics of Touring 6.1Hamilton Paths and Hamilton Circuits.
Graph Theory Hamilton Paths and Hamilton Circuits.
Chapter 4 sections 1 and 2.  Fig. 1  Not connected  All vertices are even.  Fig. 2  Connected  All vertices are even.
1 Excursions in Modern Mathematics Sixth Edition Peter Tannenbaum.
7.1 and 7.2: Spanning Trees. A network is a graph that is connected –The network must be a sub-graph of the original graph (its edges must come from the.
6.1 Hamilton Circuits and Paths: Hamilton Circuits and Paths: Hamilton Path: Travels to each vertex once and only once… Hamilton Path: Travels to each.
Module 5 – Networks and Decision Mathematics Chapter 23 – Undirected Graphs.
© 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.
Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 1 4 Graph Theory (Networks) The Mathematics of Relationships 4.
6.4: The Brute-Force Algorithms
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.
Mathematics in Management Science
CIRCUITS, PATHS, AND SCHEDULES Euler and Königsberg.
Graph Theory Hamilton Paths Hamilton Circuits and.
Euler Paths and Circuits. The original problem A resident of Konigsberg wrote to Leonard Euler saying that a popular pastime for couples was to try.
Lecture 52 Section 11.2 Wed, Apr 26, 2006
1) Find and label the degree of each vertex in the graph.
I can describe the differences between Hamilton and Euler circuits and find efficient Hamilton circuits in graphs. Hamilton Circuits I can compare and.
Chapter 14 Section 3 - Slide 1 Copyright © 2009 Pearson Education, Inc. AND.
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.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
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,
Chapter 2: Business Efficiency Hamiltonian Circuit Visiting Vertices –In some graph theory problems, it is only necessary to visit specific locations (using.
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
6.4: The Brute-Force Algorithms
Weighted Graphs and traveling Salesperson problem
CSNB 143 Discrete Mathematical Structures
Redraw these graphs so that none of the line intersect except at the vertices B C D E F G H.
Week 11 - Monday CS221.
Great Theoretical Ideas in Computer Science
Chapter 2: Business Efficiency Lesson Plan
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
Discrete Maths 9. Graphs Objective
Chapter 2: Business Efficiency Lesson Plan
Spanning Trees Discrete Mathematics.
Discrete Math: Hamilton Circuits
Section 14.3 Hamilton Paths, and Hamilton Circuits
Discrete Mathematics for Computer Science
* Hamiltonian Circuits introduction
Graph Theory.
Graphs Chapter 13.
Chapter 9: Graphs Basic Concepts
Discrete Math II Howon Kim
A path that uses every vertex of the graph exactly once.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Euler and Hamilton Paths
Classwork Worksheet Homework (day 67) worksheet
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,
Warm Up – Monday Calculate the Redundancy of the above network.
Warm Up – 3/19 - Wednesday Give the vertex set. Give the edge set.
Traveling Salesman Problems Nearest Neighbor Method
Chapter 9: Graphs Basic Concepts
Presentation transcript:

HAMILTONIAN CIRCUIT ALGORITHMS Vocabulary Application examples of Brute Force Algorithm Nearest Neighbor Algorithm

HAMILTONIAN CIRCUITS and PATHS REVIEW: A Hamiltonian Circuit is a circuit that visits each VERTEX of a graph only once. A Hamiltonian path is a path that visits each VERTEX only once.

Unlike (Euler Circuit) E. C Unlike (Euler Circuit) E.C. problems, we can not simply look at a graph and determine if it has an associated H.C. There are certain types of graphs (fortunately, the most common) that ALWAYS have an associated (Hamilton Circuit) H.C. A COMPLETE GRAPH: A graph with ‘N’ vertices in which every pair of vertices is joined by exactly one edge. In a COMPLETE GRAPH with ‘N’ vertices, each vertex has DEGREE ‘N-1’ All complete graphs have h.c. associated with them.

(For example, C and D are NOT adjacent. A and C are not adjacent) graphs… A B D C graph #1 This graph has hamiltonian paths: ADBC (or its mirror image) DABC (or its mirror image) The graph has no h.c., since you cannot leave vertex C without re-visiting vertex B This is NOT a COMPLETE graph… to prove this, you must find at least one pair of vertices that is NOT connected with an edge (not ADJACENT) (For example, C and D are NOT adjacent. A and C are not adjacent) Another way to prove it is not a complete graph is to find one at least one pair of vertices that is connected by more than one edge. (B and C, for example)

graphs… graph #2 B A C D This graph has hamiltonian paths: ACDB (or its mirror image) BACD (or mirror image) …etc... The graph has h.c.: ACDBA (or its mirror image) BACDB (or mirror image) ...etc... This is NOT a COMPLETE graph… (B and C are not adjacent)

graphs… graph #3 B A E C D This graph has many hamiltonian paths: ABCDE …etc... This graph has many H.C. ABCDEA … etc... This is a COMPLETE graph with 5 vertices… Notice that each vertex is adjacent to every other vertex exactly once, and that each has degree 4.

H.C. example… The vertices will represent cities, and the edges will represent distances(and will be measured in miles.) A D C B AB = 10 BC = 30 DC = 20 AD = 70 AC = 50 BD = 40 Recalling the example from the introductory show should remind you that there are only 3 possible H.C. subgraphs associated with this COMPLETE graph.

For COMPLETE GRAPHS… how many subgraphs? D C B 1. We looked at the same type of graph last time (the ‘lazy Fred’ example) and noticed that there were only 3 possible h.c. subgraphs. 2. We also noticed that (up to the STARTING vertex) there were two hamiltonian circuits associated with each subgraph. 3. Let’s do some math...

Tree Diagram A D B C C D B D C B For every COMPLETE graph with 4 vertices… the DEGREE of each vertex is??? C D B 3 So, once you have chosen a starting point, you have 3 vertices to chose from. D C B After you’ve chosen one of those 3, how many vertices are left to choose from? 2 Tree Diagram And after you’ve chosen one of those 2, how many vertices are left to choose from? To create the h.c., each path will return to A at the end. 1

Complete Graphs with “N” vertices… 4. Will have (N-1)x(N-2)x(N-3)x…x2 Hamiltonian Circuits associated with them. Mathematically, we will use “factorial” shorthand to write this expression. We will write: The number of H.C. for a complete graph with N vertices = (N-1)!

Complete Graphs with “N” vertices… 5. We saw that each H. subgraph could be used to describe 2 hamiltonian circuits (mirror images) 6. So, the number of Hamiltonian Circuit subgraphs for a complete graph with “N” vertices is: (N-1)!/2

back to the H.C. example… This is a complete graph with 4 vertices. D C B AB = 10 BC = 30 DC = 20 AD = 70 AC = 50 BD = 40 This is a complete graph with 4 vertices. It has (4-1)! = (3)! = 3x2 = 6 hamiltonian circuits (after you’ve chosen a starting pt.) It has (4-1)!/2 = (3)!/2 = (3x2)/2 = 6/2 = 3 h.c. subgraphs

Algorithms to find Hamiltonian circuits 9/9/2018 Algorithms to find Hamiltonian circuits They may not yield the optimal solution but will always give us an efficient approximation. We may use them a few times, sometimes with different starting points, and compare the solutions we find They ALWAYS work with COMPLETE graphs, but sometimes fail to produce a solution with other graphs

Algorithm 1: The Brute Force Method Step 1 : Make a list of all the possible Hamilton circuits of the graph. Step 2: For each HC calculate its total weight. (add up the edges in the circuit) Step 3: Choose an optimal circuit.

back to the H.C. example… This is a complete graph with 4 vertices. D C B AB = 10 BC = 30 DC = 20 AD = 70 AC = 50 BD = 40 This is a complete graph with 4 vertices. It has (4-1)! = (3)! = 3x2 = 6 hamiltonian circuits (after you’ve chosen a starting pt.) It has (4-1)!/2 = (3)!/2 = (3x2)/2 = 6/2 = 3 h.c. subgraphs

Brute Force Method… In the “Lazy Fred” example, all 3 of the possible h.c. subgraphs are examined. You should be able to see that this method is fine for such a small graph. When we try to use this method for a complete graph with 5 vertices, though, we’d have to look at: (4)!/2 = (4x3x2)/2 = 12 h.c. subgraphs. Notice how quickly this method becomes computationally inefficient.

Example 20 C B A D 10 70 50 15 30

Algorithm 2: Nearest Neighbor Start : Start at a designated vertex. First Step: From the starting vertex go to its nearest neighbor. (edge with the smallest weight. Middle Steps: Repeat step 2 until you have visited all the vertices exactly once. Last Step: From the last vertex return to the starting vertex.

NEAREST NEIGHBOR ALGORITHM 9/9/2018 NEAREST NEIGHBOR ALGORITHM A D C B AB = 10 BC = 30 DC = 20 AD = 70 AC = 50 BD = 40 1. Choose a starting vertex (ex) I choose vertex B Its nearest neighbor is 10 units away at vertex A. 2. Begin by drawing the edge that connects these points A D C B

NEAREST NEIGHBOR ALGORITHM 9/9/2018 NEAREST NEIGHBOR ALGORITHM A D C B AB = 10 BC = 30 DC = 20 AD = 70 AC = 50 BD = 40 3. Continue by choosing the nearest neighbor of the last vertex touched... A D C B BUT>>> DO NOT… >add any edge that will create a subcircuit (doesn’t contain ALL of the original vertices) >add an edge that will make a vertex have degree greater than 2 The weight of this circuit is 120 miles.