Hamiltonian paths in tournaments A generalization of sorting DM19 notes fall 2006

Similar documents
Solution of a conjecture of Volkmann on the number of vertices in longest paths and cycles of strong semicomplete multipartite digraphs

Multipartite tournaments with small number of cycles

Out-colourings of Digraphs

Paths and cycles in extended and decomposable digraphs

Cographs; chordal graphs and tree decompositions

On scores in tournaments and oriented graphs. on score sequences in oriented graphs. Also we give a new proof for Avery s

Strong Tournaments with the Fewest Hamiltonian Paths

Longest paths in strong spanning oriented subgraphs of strong semicomplete multipartite digraphs

CHAPTER 1. Relations. 1. Relations and Their Properties. Discussion

Discrete Applied Mathematics

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005

16 February 2010 Draft Version

5 Flows and cuts in digraphs

Determining conditions sufficient for the existence of arc-disjoint hamiltonian paths and out-branchings in tournaments

A counterexample to a conjecture of Schwartz

Relations Graphical View

10.3 Matroids and approximation

Disjoint paths in tournaments

Massachusetts Institute of Technology 6.042J/18.062J, Fall 02: Mathematics for Computer Science Professor Albert Meyer and Dr.

Nordhaus-Gaddum Theorems for k-decompositions

Notes. Relations. Introduction. Notes. Relations. Notes. Definition. Example. Slides by Christopher M. Bourke Instructor: Berthe Y.

Tree-width and algorithms

Discrete Optimization 23

Standard Diraphs the (unique) digraph with no vertices or edges. (modulo n) for every 1 i n A digraph whose underlying graph is a complete graph.

Acyclic and Oriented Chromatic Numbers of Graphs

Graphs and Combinatorics

Disjoint paths in unions of tournaments

CPSC 320 Sample Final Examination December 2013

Pancyclic out-arcs of a vertex in tournaments

GRAPH ALGORITHMS Week 7 (13 Nov - 18 Nov 2017)

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016)

Contents. Introduction

Reachability in K-Colored Tournaments. Adam K. Bland

Decomposing oriented graphs into transitive tournaments

ON THE NUMBER OF ALTERNATING PATHS IN BIPARTITE COMPLETE GRAPHS

Generalized Pigeonhole Properties of Graphs and Oriented Graphs

Introduction to Graph Theory

Induced Cycles of Fixed Length

Graphic sequences, adjacency matrix

4 Packing T-joins and T-cuts

Rao s degree sequence conjecture

Hamilton Cycles in Digraphs of Unitary Matrices

Paths, cycles, trees and sub(di)graphs in directed graphs

Lecture 20 : Markov Chains

K 4 -free graphs with no odd holes

IE 336 Seat # Name (clearly) Closed book. One page of hand-written notes, front and back. No calculator. 60 minutes.

REALIZING TOURNAMENTS AS MODELS FOR K-MAJORITY VOTING

Oblivious and Adaptive Strategies for the Majority and Plurality Problems

directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time

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

COE428 Notes Week 4 (Week of Jan 30, 2017)

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

On improving matchings in trees, via bounded-length augmentations 1

ACO Comprehensive Exam October 14 and 15, 2013

Algorithms Exam TIN093 /DIT602

Lesson 8: Why Stay with Whole Numbers?

Minimum Cost Homomorphisms to Semicomplete Bipartite Digraphs

A counterexample to a conjecture of Schwartz

Graph coloring, perfect graphs

CS 350 Algorithms and Complexity

CS 350 Algorithms and Complexity

Using DERIVE to Interpret an Algorithmic Method for Finding Hamiltonian Circuits (and Rooted Paths) in Network Graphs

ARC-TRACEABLE TOURNAMENTS. Arthur H. Busch. A thesis submitted to the. University of Colorado at Denver. in partial fulfillment

1.4 Equivalence Relations and Partitions

7 Matrix Operations. 7.0 Matrix Multiplication + 3 = 3 = 4

Discrete Mathematics, Spring 2004 Homework 4 Sample Solutions

About one conjecture of twin domination number of oriented graphs

1 Sequences and Summation

Chapter 9: Relations Relations

Gray Codes and Overlap Cycles for Restricted Weight Words

1 More finite deterministic automata

The domination game played on unions of graphs

An Equivalence result in School Choice

NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: Time Allowed 2 Hours

RECOGNIZING WEIGHTED DIRECTED CARTESIAN GRAPH BUNDLES

Chapter 7. Network Flow. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

The existence and uniqueness of strong kings in tournaments

Section Summary. Relations and Functions Properties of Relations. Combining Relations

Graph Theorizing Peg Solitaire. D. Paul Hoilman East Tennessee State University

On splitting digraphs

Mean-Payoff Games and the Max-Atom Problem

Nash-solvable bidirected cyclic two-person game forms

On the complexity of hamiltonian path and cycle problems in certain classes of digraphs

Ranking Score Vectors of Tournaments

Arc-chromatic number of digraphs in which every vertex has bounded outdegree or bounded indegree

1 Some loose ends from last time

Notes on Graph Theory

Definition: A binary relation R from a set A to a set B is a subset R A B. Example:

Central Groupoids, Central Digraphs, and Zero-One Matrices A Satisfying A 2 = J

Social Dichotomy Functions (extended abstract)

Copyright 2013 Springer Science+Business Media New York

Shortest paths with negative lengths

4 CONNECTED PROJECTIVE-PLANAR GRAPHS ARE HAMILTONIAN. Robin Thomas* Xingxing Yu**

The minimum G c cut problem

On the number of cycles in a graph with restricted cycle lengths

Combinatorial optimization problems

1 Hamiltonian properties

CSE 21 Practice Exam for Midterm 2 Fall 2017

Graphs with few total dominating sets

PUTNAM TRAINING MATHEMATICAL INDUCTION. Exercises

Transcription:

Hamiltonian paths in tournaments A generalization of sorting DM9 notes fall 2006 Jørgen Bang-Jensen Imada, SDU 30. august 2006 Introduction and motivation Tournaments which we will define mathematically in the next section are, besides being an interesting mathematical object, also interesting from a practical point of view. We shall show that the sorting problem is a special case of that of finding a hamiltonian path in a tournament. But let us start with a more amusing application of tournaments: Consider a soccer tournament in which every pair of distinct teams play each other exactly once and where ties are not allowed (that is in case of a tie after 90 minutes the game continues until one team has scored a goal, or, eventually the game is decided on penalties). The outcome of such a soccer tournament can be modeled as a mathematical tournament T by letting each team correspond to a vertex of T and letting T contain the arc i j precisely when team i has beaten team j. The rule that there can be no ties ensures that T will be a mathematical tournament. Since, as we shall prove below, every tournament has a hamiltonian path, it follows that one can always order the teams, 2,..., n in such a way that team i has beaten team i + for i =,..., n. Another interesting consequence is that there will always exist a team i such that for any other team j, either i has beaten j or i has beaten a team k which in turn has beaten j. You will be asked to prove this fact as one of the exercises. The main purpose of this note is to show how various algorithms for sorting numbers can be converted into algorithms for finding hamiltonian paths in (mathematical) tournaments. 2 Some mathematics A tournament is a directed graph T = (V, A) such that for every pair of distinct vertices x, y V, precisely one of the arcs x y, y x belongs to A.

2 2 3 4 5 0 0 0 2 5 2 0 0 0 0 0 3 0 0 0 4 0 0 3 4 5 0 0 Figur : A tournament T on 5 vertices and the corresponding adjacency matrix M(T ). The numbering of the vertices of T corresponds to the numbering of the rows ands columns of M(T ). Note that if T = (V, A) is a tournament, then every subset V V induces a subtournament of T and for every pair of distinct vertices v, v V, the arc v v is an arc in T if and only if v v is an arc of T. We also call T the subtournament of T induced by V. Given a tournament T on n vertices v,..., v n we can define an n n matrix M(T ) = {m ij } i,j=,...,n, whose elements are all 0 or and where m ij = m ji = 0 for i j, and m ii = 0, i =, 2,..., n. The matrix M(T ) is called the adjacency matrix of T and is defined by m i,j = v i v j is an arc of T. Figure shows a tournament on 5 vertices and the corresponding adjacency matrix. A path in a digraph D = (V, A) is a collection of vertices and arcs P = x, x x 2, x 2, x 2 x 3,..., x k x k, x k, such that the vertices x, x 2,..., x k are distinct. We say that P starts in x and ends in x k and call it an (x, x k )- path. Similarly, a cycle is a collection of vertices and arcs x, x x 2, x 2, x 2 x 3,..., x k x k, x k, x k x, such that the vertices x, x 2,..., x k are distinct. We will often just denote a path and a cycle as above by x x 2... x k respectively, x x 2... x k x. The length of a path or a cycle is the number of arcs in it. A hamiltonian path in a digraph D is a path containing all vertices of D. For example, the path 3 5 4 2 is a hamiltonian path in the tournament T in Figure. Observe that if x, x 2..., x n are distinct real numbers, then we can define a tournament T T n by letting each x i correspond to a vertex v i and letting v i v j be an arc of T T n precisely when x i < x j. Then it is easy to see that T T n does not contain any directed cycle and that T T n will be the same for any choice of n distinct real numbers with the same relative order as x, x 2..., x n. We call T T n the transitive tournament on n vertices. The name transitive comes from the fact that for all v i, v j, v k such that v i v j and v j v k are arcs of T T n, the arc v i v k also belongs to T T n. Furthermore, if we assume that x < x 2 <... < x n then v v 2... v n is the unique hamiltonian path of T. As we shall show below, every tournament has a hamiltonian path. Thus it follows that the sorting

3 problem is a special case of that of finding a hamiltonian path in a tournament. By this we mean the following: any algorithm for finding a hamiltonian path in a tournament can be used to sort a set of n numbers, since for tournaments defined from sets of distinct numbers as above there is precisely one hamiltonian path, the one corresponding to sorting the numbers in ascending order. In Algorithm 2 below we shall make use of the following lemma. Lemma Let x x 2... x r, r 2, be a path in a tournament T and let x be a vertex not on this path. If both x x and x x r are arcs of T, then there exists an index i r, such that x i x and x x i+ are both arcs of T. Hence x... x i x x i+... x r is a path in T. Proof: Let i be the largest index such that x i x is an arc of T. Since x x r (implying that x r x is not an arc of T!) it follows that i r and by the maximality of i we must have x x i+. q.e.d. 3 Algorithms for finding a hamiltonian path in a tournament Below we shall sketch two algorithms for finding a hamiltonian path in a tournament. These are based on two of the most fundamental principles that were covered in the course DM02, namely divide and conquer and incremental algorithms. Algorithm : This is an adaption of the well-know Merge-sort algorithm to tournaments:. Partition the vertex set of T into two disjoint sets V and V 2 of equal or (if the number of vertices is odd) almost equal size. Denote by T i the subtournament of T induced by V i for i =, 2. 2. Find recursively a hamiltonian path P i in T i, i =, 2. 3. Merge the paths P and P 2 into one path as follows: Let P = x x 2... x k and P 2 = x k+ x k+2... x k+l, k = l or k = l +, be the two paths that we wish to merge into a hamiltonian path of T. Since T is a tournament, either x x k+ or conversely. Assume without loss of generality below that x x k+. Find an index i such that x i x k+ and either i = k or x k+ x i+. If i = k we are done, since then x k x k+ and it is easy to construct a hamiltonian path of T. Suppose that i < k. Repeat the above process with the two paths x i+... x k and x k+... x k+l. The merging is completed when one of the two remaining paths becomes empty. Figure 2 shows an example of the merging process.

4 P P 2 Figur 2: An example of a merging of two paths. The dotted line indicates the resulting hamiltonian path. Algorithm 2: This is the equivalent of insertion sort for tournaments.. Let v,..., v n be an arbitrary ordering of the vertices of the tournament T. 2. Consider the vertices v and v 2. The unique arc between x and x 2 forms a hamiltonian path in the subtournament induced by v and v 2. 3. In the k th step, 3 k n, we proceed as follows: Let x... x k be the current hamiltonian path which the algorithm has found in the tournament induced by the vertices v,..., v k. Consider the arcs between the next vertex v k and this path. 4. If v k x, then v k x... x k is a hamiltonian path in the subtournament induced by v,..., v k. Go to step 3 and consider the (k + ) st vertex. 5. Otherwise, if x k v k is an arc of T, then x... x k v k is a hamiltonian path in the subtournament induced by v,..., v k. Go to step 3 and consider the (k + ) st vertex. 6. (now we know that both x v k and v k x k are arcs of T, implying, by Lemma, that v k can be inserted somewhere inside that path x... x k ). Find x i, i k 2, such that x i v k and v k x i+ are both arcs. Let x... x i v k x i+... x k be the new path and go to step 3 with the (k + ) st vertex. It is easy to see that the approach above can be converted into a proof by induction on the number of vertices of the following result. Theorem Every tournament has a hamiltonian path.

5 4 Exercises. Prove that every tournament T = (V, A) has a vertex v such that v can reach every other vertex by a path of length at most 2 (i.e., for every u V v, either v u is an arc of T or there exists a vertex z V {u, v} such that v z and z u are both arcs of T. Hint: consider a vertex with the maximum number of arcs starting in it. 2. Let T = (V, A) be a tournament and let P, Q be two paths, both of which start in x and end in y and which have no other common vertices (that is, they meet only at the ends). (a) Prove that T has a path R which starts in x, ends in y and which contains precisely those vertices which belong to one of the paths P, Q (that is V (R) = V (P ) V (Q)). Hint: prove that the paths can be merged as in Algorithm. (b) Describe a linear algorithm which, given two paths P, Q as above in a tournament, finds a path R as above. Hint: use the fact that one can construct R starting from the first vertex which is x and then proceeding forward along the two paths (as when one zips a fly), see Figure 2). 3. Describe how to implement Algorithm and 2 such that the running times are O(n log n) and O(n 2 ), respectively, when we measure the complexity as the number of times we need to look up the direction of an arc in the adjacency matrix. 4. A digraph D = (V, A) is strongly connected if it contains and (x, y)-path for every choice of vertices x, y V. Prove that every strongly connected tournament has a hamiltonian cycle, that is, a cycle which contains all vertices of T. Hint: Start with a cycle C and conclude that if C is not a hamiltonian cycle, then, since T is strongly connected, one can extend the cycle C by adding one or more vertices. Here you can use Lemma. 5. Convert you proof above to an algorithm for finding a hamiltonian cycle in a tournament and give the complexity of your algorithm.