Presentation is loading. Please wait.

Presentation is loading. Please wait.

Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)

Similar presentations


Presentation on theme: "Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)"— Presentation transcript:

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

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

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

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

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

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

7 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

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

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

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

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

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

13 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

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

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

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

17 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

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

19 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

20 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

21 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

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


Download ppt "Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)"

Similar presentations


Ads by Google