Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)

Slides:



Advertisements
Similar presentations
CS 336 March 19, 2012 Tandy Warnow.
Advertisements

22C:19 Discrete Math Graphs Fall 2014 Sukumar Ghosh.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
Great Theoretical Ideas in Computer Science for Some.
Introduction to Graph Theory Lecture 11: Eulerian and Hamiltonian Graphs.
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Combinatorial Algorithms
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Introduction to Approximation Algorithms Lecture 12: Mar 1.
Approximation Algorithms: Combinatorial Approaches Lecture 13: March 2.
An Euler Circuit is a cycle of an undirected graph, that traverses every edge of the graph exactly once, and ends at the same node from which it began.
GRAPH Learning Outcomes Students should be able to:
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
EECS 203: It’s the end of the class and I feel fine. Graphs.
The Traveling Salesman Problem Approximation
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
CS 200 Algorithms and Data Structures
Techniques for Proving NP-Completeness Show that a special case of the problem you are interested in is NP- complete. For example: The problem of finding.
Approximation Algorithms for TSP Tsvi Kopelowitz 1.
Lecture 52 Section 11.2 Wed, Apr 26, 2006
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
Approximation Algorithms by bounding the OPT Instructor Neelima Gupta
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
Graphs. Representations of graphs : undirected graph An undirected graph G have five vertices and seven edges An adjacency-list representation of G The.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
An Introduction to Graph Theory
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
The Theory of NP-Completeness
More NP-Complete and NP-hard Problems
More NP-complete problems
Introduction to Approximation Algorithms
EECS 203 Lecture 19 Graphs.
Euler and Hamiltonian Graphs
Richard Anderson Lectures NP-Completeness
Graphs Hubert Chan (Chapter 9) [O1 Abstract Concepts]
Richard Anderson Lecture 26 NP-Completeness
Bipartite Matching Lecture 8: Oct 7.
Richard Anderson Lecture 26 NP-Completeness
Graphs Rosen, Chapter 8.
Graph theory Definitions Trees, cycles, directed graphs.
Eulerian tours Miles Jones MTThF 8:30-9:50am CSE 4140 August 15, 2016.
EECS 203 Lecture 20 More Graphs.
Algorithms and Networks
Great Theoretical Ideas in Computer Science
Planarity Testing.
Approximation Algorithms for TSP
The Art Gallery Problem
Discrete Mathematics for Computer Science
CSE 421: Introduction to Algorithms
Can you draw this picture without lifting up your pen/pencil?
ICS 353: Design and Analysis of Algorithms
The Art Gallery Problem
Introduction to Graph Theory Euler and Hamilton Paths and Circuits
Graph Theory.
Graphs Chapter 13.
Richard Anderson Lecture 25 NP-Completeness
Richard Anderson Lecture 28 NP-Completeness
Discrete Math II Howon Kim
Richard Anderson Lecture 30 NP-Completeness
5.4 T-joins and Postman Problems
Proof Techniques.
Euler and Hamilton Paths
Euler and Hamiltonian Graphs
The Theory of NP-Completeness
Applied Combinatorics, 4th Ed. Alan Tucker
Hamiltonian Circuit (HC) problem
Lecture 24 Vertex Cover and Hamiltonian Cycle
Presentation transcript:

Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5) [O1 Abstract Concepts] [O2 Proof Techniques] [O3 Basic Analysis Techniques]

Hamiltonian Paths and Circuits [O1] A Hamiltonian path is a path containing every vertex once and only once. (“Visit” all vertices exactly once) A Hamiltonian cycle/circuit is a circuit containing every vertex once and only once.(“Visit” all vertices exactly once with a cycle) Example: (round-the-world puzzle)

Comparing Euler and Hamiltonian Circuit/Path A connected graph has an Euler circuit iff all vertices have even degrees. A connected graph has an Euler path (but not an Euler circuit) iff exactly two vertices have odd degrees. A Hamiltonian path/circuit is a path/circuit containing every vertex once and only once. Unlike Euler paths/circuits, there is NO simple condition to check whether a graph has a Hamiltonian path/circuit.

Existence of Hamiltonian Paths Unlike Euler paths/circuits, there is no simple condition to check whether a graph has a Hamiltonian path/circuit. Q3 K6 ? The problem checking whether a given graph has a Hamiltonian path/circuit is NP-hard. That is, the best method known required at least exponential time w.r.t. the size of the graph (number of vertices/edges), and it is unlikely that there exists a polynomial time algorithm for this problem.

Special Case: Tournament Graph A tournament graph on n vertices is a directed graph such that for all x  y, exactly one of the edges (x, y), (y, x) is in the graph. Interpretation: In a round-robin tournament, each player plays with every other player exactly once. Each vertex stands for a player and each edge for a match. A directed edge (x,y) means that player x beats player y. There is no draw.

Hamiltonian Path for Tournament Graph Theorem. Every tournament graph has a Hamiltonian path. For example, n = 5

Proof of the Existence of HP [O2] Theorem: Every tournament graph has a Hamiltonian path. Proof: By induction on the number of vertices, n. Basis: n = 2, it is true trivially Inductive Step: Assume it is true for n – 1 There exists a HP (v1, v2, …, vn–1) for the directed complete graph of n – 1 vertices. There are directed edges joining vn to {v1, v2, …, vn–1} Want to prove that it is true for n. v1 v2 v1 vn v7 v6 v5 v4 v3 v2 vn-1 vn-2 vn-3

Induction Step on the Existence Proof Inductive Step: Assume it is true for n – 1 There exists a HP (v1, v2, …, vn–1) for the directed complete graph of n – 1 vertices. There are directed edges joining vn to {v1, v2, …, vn–1} v1 v2 v3 v4 vk –1 vk vn –1 vn If vn  v1, then vn v1, v2, …, vn–1 (done) If v1  vn and vn  v2, then v1 vn v2 …vn–1 (done) If v1  vn, v2  vn and vn  v3, then v1 v2 vn v3 …vn–1 (done) If {v1 , v2 , v3}  vn and vn  v4, then v1 v2 v3 vn v4 …vn–1 (done) … If {v1 , v2 , …, vk –1}  vn and vn  vk, then v1 … vk –1 vn vk …vn–1 (done) … If {v1 , v2 , …, vn –2}  vn and vn  vn-1, then v1 … vn –2 vn vn-1(done) If {v1 , v2 , …, vn –1}  vn then v1 … vn –1 vn (done)

Proof of non-existence of HC [O3] Does there exist a Hamiltonian Circuit or Path for the graph on the right? Observations: There is no 3-cycles (cycle of 3 vertices) in G. G is a bipartite graph. e c g d h i j f b a a b c d f h j e g i V0 V1 If G is to have a HC/HP, it must be an alternating sequence of V0 and V1 vertices. The numbers of V0 and V1 vertices in HC/HP should not differ more than 1. Since the difference of |V0| and |V1| is 2, G cannot have a HC/HP.

Extension of the non-existence proof A subset S of vertices in a graph is an independent set if for any u,v in S, there is no edge between u and v. Theorem: Suppose G has n vertices and an independent set S of size greater than n/2. Then, G does not have a HC. Proof: Any path in G must have the circled vertex (in S) followed by an un-circled vertex (not in S). Since more than 1/2 of the vertices are circled, any HC must contain an edge containing two circled vertices. Conclusion: HC cannot exist.

Hamiltonian Graphs: Some simple criteria Unlike the simple criterion for Eulerian graphs, no simple test is known that says a graph is or isn't Hamiltonian. Some necessary conditions for a Hamiltonian cycle: No degree-1 vertices No cut vertices (a vertex whose removal will disconnect a graph) No bridges (an edge whose removal will disconnect a graph) If a vertex has degree 2, both edges are on any hamiltonian cycle If a vertex has degree >2, and you find 2 incident edges that must be on any hamiltonian cycle, then the other incident edges can't! For a Hamiltonian path: at most two degree-1 vertices; if so, they're at ends of the path.

Example Use ideas from last slide to show graph below has a unique Hamiltonian cycle: X

A sufficiency theorem for Hamiltonian graphs General theme of various theorems is that if G has enough edges, then it is Hamiltonian. Dirac's Theorem: Let G be a simple graph with n vertices, where n  3. If deg(v)  n/2 for each v, then G is Hamiltonian

Proving Dirac's Theorem Proof by contradiction: A proof of Louis Posa, a child prodigy from Hungary Assume deg(v)  n /2, for all v, but G is not Hamiltonian Add as many edges to G as possible, keeping it non-Hamiltonian. Resulting graph (still call it G) is called maximal non-Hamiltonian. G still satisfies deg(v)  n/2, for all v There must exist a pair of non-adjacent vertices v and w. Why? If we add the edge v-w to G, then G υ {v,w} must be Hamiltonian There must be Hamiltonian path P from v to w -- why?

Finishing proof of Dirac's Theorem Number the vertices of G as they appear on P: v = v1, v2, …, vn-1, vn = w Consider N = {v2, v3, …, vn-2}, observe |N| = n-3. Consider 2 subsets of N: A = {u 2 N: u is w’s neighbor} B = {u 2 N: u comes before a neighbor of v} If A and B are not disjoint, G has a Hamiltonian cycle, v=v1,v2,... wi,w=vn, vn-1 ... vi,v contradiction!! |A| ≥ n/2 -1: w has at least n/2 neighbors, but one of them is vn-1 (not in N) |B| ≥ n/2 -1: v has at least n/2 neighbors, and hence at least so many nodes come before a neighbor of v. But, v1 is not in N. If A and B are disjoint, then |A [ B| ≥ n -2.

Sufficient Conditions for Hamiltonian Circuit/Path Observation: HC exists if the graph has many edges, (Dirac’s Theorem) If G is a simple graph with n  3 vertices and deg(v)  n/2 for all v, then G has a Hamiltonian circuit. (Ore’s Theorem) If G is a simple graph with n  3 vertices such that deg(u) + deg(v)  n for every pair of nonadjacent vertices u and v in G, then G has a Hamiltonian circuit. Dirac’s Theorem can be proved as a corollary of Ore’s If deg(v)  n/2 for all v, then obviously deg(u) + deg(v)  n for any pair of vertices u and v in G.

Knight’s Tour Knight's Tour - A knight is placed on the empty chessboard and, moving according to the rules of chess, must visit each square exactly once (open or closed). Construct an access graph: each position as a vertex and each possible move as an edge. Does an n x n board has a knight’s tour? A 5x5 board? An open tour exists

All 4 x n Chessboard (from Posa) All 4 x n chessboards do not have any closed Knight’s tour. Proof: Consider the board colored with black and white. All moves have to be alternate between black and white. Consider another board coloring, top and bottom rows red and middle two rows blue. When a knight is on a red square, its next square must be blue. The move after a blue square has to be red too. Otherwise there will be unvisited red squares, as the number of red and blue square are the same. This is impossible as the knight have to follow two colorings.

Traveling Salesman Problem A Traveling salesman wants to visit each of n cities exactly once and return to his starting point. Traveling Salesman Problem (TSP): Given a weighted, complete, undirected graph, find a circuit of minimum total weight, which visits each vertex exactly once. 7 1 2 10 8 3 5 6 4 e a b c d weight (a b c d e) = 24 weight (c d a e b) = 23 weight (a c b d e) = 21 We can find the optimal TSP circuit by exhaustion, i.e., to find the weights of all the (n-1)! Hamiltonian circuits

Which is more difficult: TSP or HC? HC problem can be reduced to TSP The graph G(V, E) for the HC problem will be transformed to a weighted graph G’(V’, E’) for the TSP. We try to solve the HC problem by solving the TSP problem. HC: Input = G(V, E); Output = “yes” / “no” TSP: Input = weighted graph G’(V’, E’) Output = minimum-weighted circuit Transform to weighted graph Weighted graph Algorithm to solve TSP Input for HC, G(V,E) Transform to Output for HC Min-weighed circuit Output for HC, Yes/no

Traveling Salesman Problem and Hamiltonian Circuit Problem HC problem can be reduced to TSP The graph G(V, E) for the HC problem will be transformed to a weighted graph G’(V’, E’) for the TSP. G G’ is a complete graph with V’ = V and w(e) = 1 if e is in E w(e) = M if e is not in E, where M is a constant > n G’ G’ has a TSP circuit of weight |V| iff HC exists in G As we can solve the HC problem by solving the TSP problem. So TSP is at least as difficult as the HC problem, i.e., NP-hard. 1 M

Summary on Hamiltonian Circuit A Hamiltonian circuit (or path) is a circuit (or path) containing every vertex once and only once. The problem checking whether a given graph has a Hamiltonian path/circuit is NP-hard, i.e, in exponential time by exhaustion. Traveling Salesman Problem (TSP): Given a weighted, complete, undirected graph, find a circuit of minimum total weight, which visits each vertex exactly once. HC problem can be reduced to TSP. So TSP is at least as difficult as the HC problem, i.e., NP-hard.