Hamiltonian Graphs Graphs

Similar documents
Polynomial-time Reductions

6 Euler Circuits and Hamiltonian Cycles

1 Hamiltonian properties

NP-Complete Problems. More reductions

The P versus NP Problem. Ker-I Ko. Stony Brook, New York

Lecture 4: NP and computational intractability

CS 301: Complexity of Algorithms (Term I 2008) Alex Tiskin Harald Räcke. Hamiltonian Cycle. 8.5 Sequencing Problems. Directed Hamiltonian Cycle

Algorithms Design & Analysis. Approximation Algorithm

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

8.3 Hamiltonian Paths and Circuits

Connection MATH Connection. Benjamin V.C. Collins, James A. Swenson MATH 2730

Basic definitions. Remarks

Data Structures in Java

Polynomial-Time Reductions

SAT, Coloring, Hamiltonian Cycle, TSP

ABHELSINKI UNIVERSITY OF TECHNOLOGY

Classes of Problems. CS 461, Lecture 23. NP-Hard. Today s Outline. We can characterize many problems into three classes:

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2)

CS 583: Algorithms. NP Completeness Ch 34. Intractability

8.5 Sequencing Problems

Design and Analysis of Algorithms

4/12/2011. Chapter 8. NP and Computational Intractability. Directed Hamiltonian Cycle. Traveling Salesman Problem. Directed Hamiltonian Cycle

NP Complete Problems. COMP 215 Lecture 20

Data Structures and Algorithms

Algorithms, Lecture 3 on NP : Nondeterminis7c Polynomial Time

Traveling Salesman Problem (TSP) - Visit every city and then go home.

Polynomial-time reductions. We have seen several reductions:

Data Structures and Algorithms

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

ACO Comprehensive Exam October 14 and 15, 2013

NP and Computational Intractability

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

NP-Complete Problems and Approximation Algorithms

List of Theorems. Mat 416, Introduction to Graph Theory. Theorem 1 The numbers R(p, q) exist and for p, q 2,

Warm-up Find the shortest trip (total distance) starting and ending in Chicago and visiting each other city once.

Planar Graphs (1) Planar Graphs (3) Planar Graphs (2) Planar Graphs (4)

CSCI3390-Lecture 17: A sampler of NP-complete problems

Limitations of Algorithm Power

VIII. NP-completeness

NP-complete Problems

Chapter 3: Proving NP-completeness Results

Computational Intractability 2010/4/15. Lecture 2

ACO Comprehensive Exam March 17 and 18, Computability, Complexity and Algorithms

Hamiltonian Cycle. Zero Knowledge Proof

P and NP. Inge Li Gørtz. Thank you to Kevin Wayne, Philip Bille and Paul Fischer for inspiration to slides

NP-Complete Problems

Observation 4.1 G has a proper separation of order 0 if and only if G is disconnected.

CS 350 Algorithms and Complexity

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

Observation 4.1 G has a proper separation of order 0 if and only if G is disconnected.

Cographs; chordal graphs and tree decompositions

Data Structures and Algorithms (CSCI 340)

Dynamic Programming on Trees. Example: Independent Set on T = (V, E) rooted at r V.

Algorithm Design Strategies V

Data Structures in Java. Session 22 Instructor: Bert Huang

Graduate Algorithms CS F-21 NP & Approximation Algorithms

Unit 7 Day 4 Section 4.5 & Practice Hamiltonian Circuits and Paths

Automata Theory CS Complexity Theory I: Polynomial Time

Graph Theory and Optimization Computational Complexity (in brief)

10.4 The Kruskal Katona theorem

CS 350 Algorithms and Complexity

Topics in Graph Theory

Exact Algorithms for Dominating Induced Matching Based on Graph Partition

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016)

NP-Completeness. Until now we have been designing algorithms for specific problems

NP-Completeness. ch34 Hewett. Problem. Tractable Intractable Non-computable computationally infeasible super poly-time alg. sol. E.g.

Ring Sums, Bridges and Fundamental Sets

Preliminaries and Complexity Theory

1. Introduction Recap

Some Algebra Problems (Algorithmic) CSE 417 Introduction to Algorithms Winter Some Problems. A Brief History of Ideas

NP-completeness. Chapter 34. Sergey Bereg

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Very few Moore Graphs

Approximation Algorithms for Asymmetric TSP by Decomposing Directed Regular Multigraphs

Bounds on the Traveling Salesman Problem

Graphs with large maximum degree containing no odd cycles of a given length

P and NP. Warm Up: Super Hard Problems. Overview. Problem Classification. Tools for classifying problems according to relative hardness.

Hamiltonian problem on claw-free and almost distance-hereditary graphs

LECTURE 1: INTRODUCTION

Preliminaries. Graphs. E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)}

4/20/11. NP-complete problems. A variety of NP-complete problems. Hamiltonian Cycle. Hamiltonian Cycle. Directed Hamiltonian Cycle

8.5 Sequencing Problems. Chapter 8. NP and Computational Intractability. Hamiltonian Cycle. Hamiltonian Cycle

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM

P, NP, NP-Complete. Ruth Anderson

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005

ON COST MATRICES WITH TWO AND THREE DISTINCT VALUES OF HAMILTONIAN PATHS AND CYCLES

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Chapter 8. NP and Computational Intractability

Traveling Salesman Problem

University of Washington March 21, 2013 Department of Computer Science and Engineering CSEP 521, Winter Exam Solution, Monday, March 18, 2013

Circuits. CSE 373 Data Structures

Outline. 1 NP-Completeness Theory. 2 Limitation of Computation. 3 Examples. 4 Decision Problems. 5 Verification Algorithm

Analysis of Algorithms. Unit 5 - Intractable Problems

NP-Completeness. NP-Completeness 1

Informatique Fondamentale IMA S8

Fast exact algorithms for hamiltonicity in claw-free graphs

NP and Computational Intractability

Transcription:

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

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) 2

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. 3

Existence of Hamiltonian Paths Unlike Euler paths/circuits, there is no simple condition to check whether a graph has a Hamiltonian path/circuit.? K 6 Q 3 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. 4

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. 5

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

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 v v2 3 There exists a HP (v 1, v 2,, v n 1 ) v 5 for the directed complete graph v 4 of n 1 vertices. v 1 v n-1 There are directed edges joining v n to {v 1, v 2,, v n 1 } v Want to prove that it is true for n. n-2 v 1 v 2 v 6 v n-3 v n v 7 7

Induction Step on the Existence Proof Inductive Step: Assume it is true for n 1 There exists a HP (v 1, v 2,, v n 1 ) for the directed complete graph of n 1 vertices. v 1 v n There are directed edges joining v n to {v 1, v 2,, v n 1 } v 4 v 3 If v n v 1, then v n v 1, v 2,, v n 1 (done) v k 1 If v 1 v n and v n v 2, then v 1 v n v 2 v n 1 (done) If v 1 v n, v 2 v n and v n v 3, then v 1 v 2 v n v 3 v n 1 (done) If {v 1, v 2, v 3 } v n and v n v 4, then v 1 v 2 v 3 v n v 4 v n 1 (done) If {v 1, v 2,, v k 1 } v n and v n v k, then v 1 v k 1 v n v k v n 1 (done) If {v 1, v 2,, v n 2 } v n and v n v n-1, then v 1 v n 2 v n v n-1 (done) If {v 1, v 2,, v n 1 } v n v 2 then v 1 v n 1 v n (done) v k v n 1 8

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. If G is to have a HC/HP, it must be an alternating sequence of V 0 and V 1 vertices. The numbers of V 0 and V 1 vertices in HC/HP should not differ more than 1. Since the difference of V 0 and V 1 is 2, G cannot have a HC/HP. j i a e g i b e a d h c g b c d f j h V 0 V 1 f 9

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. 10

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. 11

Example Use ideas from last slide to show graph below has a unique Hamiltonian cycle: 2 4 5 1 8 X 3 X X 7 6 12

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 13

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? 14

Finishing proof of Dirac's Theorem Number the vertices of G as they appear on P: v = v 1, v 2,, v n-1, v n = w Consider N = {v 2, v 3,, v n-2 }, observe N = n-3. Consider 2 subsets of N: A = {u N: u is w s neighbor} B = {u N: u comes before a neighbor of v} If A and B are not disjoint, G has a Hamiltonian cycle, v=v 1,v 2,... w i,w=v n,v n-1... v i,v contradiction!! v v = v1 v2 vr w =vn A n/2-1: w has at least n/2 neighbors, but one of them is v n-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, v 1 is not in N. If A and B are disjoint, then A B n -2. wi vj w 15

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. 16

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 17

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. 18

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. weight (a b c d e) = 24 weight (c d a e b) = 23 weight (a c b d e) = 21 e 4 d 7 1 2 6 a 0 10 8 3 5 c b We can find the optimal TSP circuit by exhaustion, i.e., to find the weights of all the (n-1)! Hamiltonian circuits 19

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 Input for HC, G(V,E) Output for HC, Yes/no Transform to weighted graph Transform to Output for HC Weighted graph Min-weighed circuit Algorithm to solve TSP 20

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 is a complete graph with V = V and G w(e) = 1 if e is in E w(e) = M if e is not in E, where M is a constant > n G has a TSP circuit of weight V iff HC G 1 exists in G 1 As we can solve the HC problem by solving 1 M the TSP problem. So TSP is at least as difficult as the HC problem, i.e., NP-hard. 1 1 M M M 1 21

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. 22