15-251 Great Theoretical Ideas in Computer Science.

Slides:



Advertisements
Similar presentations
6.896: Topics in Algorithmic Game Theory Lecture 21 Yang Cai.
Advertisements

Lecture 15. Graph Algorithms
Great Theoretical Ideas in Computer Science
Great Theoretical Ideas in Computer Science for Some.
22C:19 Discrete Math Graphs Fall 2010 Sukumar Ghosh.
Introduction to Graph Theory Instructor: Dr. Chaudhary Department of Computer Science Millersville University Reading Assignment Chapter 1.
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.
Greedy Algorithms Greed is good. (Some of the time)
Great Theoretical Ideas in Computer Science for Some.
1 Discrete Structures & Algorithms Graphs and Trees: III EECE 320.
Approximation Algorithms for TSP
CompSci 102 Discrete Math for Computer Science April 19, 2012 Prof. Rodger Lecture adapted from Bruce Maggs/Lecture developed at Carnegie Mellon, primarily.
Combinatorial Algorithms
Great Theoretical Ideas in Computer Science.
Last time: terminology reminder w Simple graph Vertex = node Edge Degree Weight Neighbours Complete Dual Bipartite Planar Cycle Tree Path Circuit Components.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Approximation Algorithms: Combinatorial Approaches Lecture 13: March 2.
Branch and Bound Similar to backtracking in generating a search tree and looking for one or more solutions Different in that the “objective” is constrained.
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
Approximation Algorithms
Graph Colouring Lecture 20: Nov 25.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
Introduction Outline The Problem Domain Network Design Spanning Trees Steiner Trees Triangulation Technique Spanners Spanners Application Simple Greedy.
Approximation Algorithms Motivation and Definitions TSP Vertex Cover Scheduling.
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
GRAPH Learning Outcomes Students should be able to:
Data Structures and Algorithms Graphs Minimum Spanning Tree PLSD210.
Minimal Spanning Trees What is a minimal spanning tree (MST) and how to find one.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem.
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
Slide 14-1 Copyright © 2005 Pearson Education, Inc. SEVENTH EDITION and EXPANDED SEVENTH EDITION.
The Traveling Salesman Problem Approximation
University of Texas at Arlington Srikanth Vadada Kishan Kumar B P Fall CSE 5311 Solving Travelling Salesman Problem for Metric Graphs using MST.
SPANNING TREES Lecture 21 CS2110 – Spring
1 The TSP : NP-Completeness Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell.
Graph Theory Topics to be covered:
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
Great Theoretical Ideas in Computer Science.
2003 ICTM Contest Division A Orals Topic: Graph Theory
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms.
Greedy Algorithms and Matroids Andreas Klappenecker.
V Spanning Trees Spanning Trees v Minimum Spanning Trees Minimum Spanning Trees v Kruskal’s Algorithm v Example Example v Planar Graphs Planar Graphs v.
Lecture 19 Greedy Algorithms Minimum Spanning Tree Problem.
Introduction to Graph Theory
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Graph Colouring Lecture 20: Nov 25. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including.
Approximation Algorithms for TSP Tsvi Kopelowitz 1.
Chapter 9 Finding the Optimum 9.1 Finding the Best Tree.
Matching Lecture 19: Nov 23.
SPANNING TREES Lecture 20 CS2110 – Fall Spanning Trees  Definitions  Minimum spanning trees  3 greedy algorithms (incl. Kruskal’s & Prim’s)
SPANNING TREES Lecture 21 CS2110 – Fall Nate Foster is out of town. NO 3-4pm office hours today!
Introduction to Graph Theory
Great Theoretical Ideas in Computer Science for Some.
COMPSCI 102 Introduction to Discrete Mathematics.
Approximation Algorithms by bounding the OPT Instructor Neelima Gupta
Instructor Neelima Gupta Table of Contents Introduction to Approximation Algorithms Factor 2 approximation algorithm for TSP Factor.
Great Theoretical Ideas In Computer Science
Minimum Spanning Trees
Great Theoretical Ideas in Computer Science
Approximation Algorithms for TSP
Discrete Mathematics for Computer Science
CSCE350 Algorithms and Data Structure
Autumn 2015 Lecture 11 Minimum Spanning Trees (Part II)
Discrete Mathematics for Computer Science
Spanning Trees Lecture 20 CS2110 – Spring 2015.
Presentation transcript:

Great Theoretical Ideas in Computer Science

Graphs II Lecture 19, October 26, 2010 Anupam Gupta Danny Sleator

Recap

The number of labeled trees on n nodes is n n-2 Cayley’s Formula

A graph is planar if it can be drawn in the plane without crossing edges Kuratowski’s Theorem A graph G is planar if and only if K 3,3 and K 5 are not minors of G. The 5-color theorem and the 4-color theorem

Euler’s Formula If G is a connected planar graph with n vertices, e edges and f faces, then n – e + f = 2

Spanning Trees A spanning tree of a graph G is a tree that touches every node of G and uses only edges from G Every connected graph has a spanning tree

Counting Spanning Trees How can we count the number of spanning trees in a graph? Brute force: try all subsets of n-1 edges. e n-1 ( ) There’s a faster way.

Counting Spanning Trees Efficiently Form the Laplacian of the graph. This is an nxn matrix L, where: L i j = Degree(i) if i=j -1 if (i,j) ∈ E otherwise L =

Counting Spanning Trees Efficiently Matrix-Tree Theorem: The number of spanning trees of a graph is the determinant of the Laplacian with one row and column removed. Proof: Beyond the scope of this course

L = = 11 (do on doc cam) Number of spanning trees = 11(do on doc cam)

If G is the complete graph on n nodes what happens? We have this (n-1)x(n-1) det: n-1 -1 … n-1… … n-1 Subtract 1 st column from every other column n-1 -n … -n -1 n … … n Add every one of the rows to the first 1 0 … 0 -1 n … … n = n n-2 Cayley’s Formula!

This is a beautiful example from Which involves using linear algebra to study and compute things on graphs

Finding Minimum Spanning Trees Say that each edge in a graph has a cost. A very natural question to ask is: i.e: what is the minimum spanning tree of the graph? What is the cheapest subset of edges that connect the nodes?

Finding Optimal Trees Problem: Find a minimum spanning tree, that is, a tree that has a node for every node in the graph, such that the sum of the edge weights is minimum

Minimum Spanning Trees

Kruskal’s Algorithm A simple algorithm for finding a minimum spanning tree

Finding an MST: Kruskal’s Algorithm Create a forest where each node is a separate tree Make a sorted list of edges S While S is non-empty: Remove an edge from S with minimal weight If it connects two different trees, add the edge. Otherwise discard it.

Applying the Algorithm

Proving the Algorithm Works The algorithm outputs a spanning tree T. Let M be a minimum spanning tree. Let e be the first edge chosen by the algorithm that is not in M. N = M+e-f is another spanning tree. Suppose that it’s not minimal. (For simplicity, assume all edge weights in graph are distinct) If we add e to M, it creates a cycle. Since this cycle isn’t fully contained in T, it has an edge f not in T.

Proving the Algorithm Works N = M+e-f is another spanning tree. Claim: e < f, and therefore N < M Suppose not: e > f Then f would have been visited before e by the algorithm, but not added, because adding it would have formed a cycle. But all of these cycle edges are also edges of M, since e was the first edge not in M. This contradicts the assumption M is a tree.

Greed is Good (In this case…) The greedy algorithm, by adding the least costly edges in each stage, succeeds in finding an MST But — in math and life — if pushed too far, the greedy approach can lead to bad results.

TSP: Traveling Salesman Problem Given a number of cities and the costs of traveling from any city to any other city, what is the cheapest round-trip route that visits each city at least once and then returns to the starting city?

TSP from Trees We can use an MST to derive a TSP tour that is no more expensive than twice the optimal tour. Idea: walk “around” the MST and take shortcuts if a node has already been visited. We assume that all pairs of nodes are connected, and edge weights satisfy the triangle inequality d(x,y) ≤ d(x,z) + d(z,y)

Tours from Trees This is a 2-competitive algorithm Shortcuts only decrease the cost, so Cost(Greedy Tour) ≤ 2 Cost(MST) ≤ 2 Cost(Optimal Tour)

Bipartite Graph A graph is bipartite if the nodes can be partitioned into two sets V 1 and V 2 such that all edges go only between V 1 and V 2 (no edges go from V 1 to V 1 or from V 2 to V 2 )

Dancing Partners A group of 100 boys and girls attend a dance. Every boy knows 5 girls, and every girl knows 5 boys. Can they be matched into dance partners so that each pair knows each other?

Dancing Partners

Perfect Matchings Regular Bipartite Matching Theorem: If every node in a bipartite graph has the same degree d ≥ 1, then the graph has a perfect matching. Note: if degrees are the same then |A| = |B|, where A is the set of nodes “on the left” and B is the set of nodes “on the right” A matching is a set of edges, no two of which share a vertex. The matching is perfect if it includes every vertex.

If there are m boys, there are md edges If there are n girls, there are nd edges Proof: Claim: If degrees are the same then |A| = |B| A Matter of Degree The Regular Bipartite Matching Theorem follows from a stronger theorem, which we now come to. (Remind me to return to the proof of the RBMT later.)

The Marriage Theorem Theorem: A bipartite graph has a perfect matching if and only if |A| = |B| = n and for all k ∈ [1,n]: for any subset of k nodes of A there are at least k nodes of B that are connected to at least one of them.

The condition fails for this graph The Marriage Theorem For any subset of (say) k nodes of A there are at least k nodes of B that are connected to at least one of them

k n-k< n-k k> The condition of the theorem still holds if we swap the roles of A and B: If we pick any k nodes in B, they are connected to at least k nodes in A The Feeling is Mutual Proof by Contradiction: AB

Proof of Marriage Theorem Call a bipartite graph “matchable” if it has the same number of nodes on left and right, and any k nodes on the left are connected to at least k on the right Strategy: Break up the graph into two matchable parts, and recursively partition each of these into two matchable parts, etc., until each part has only two nodes

Proof of Marriage Theorem Select two nodes a ∈ A and b ∈ B connected by an edge Idea: Take G 1 = (a,b) and G 2 = everything else If G 2 is matchable, we’re done. So let’s assume that G 2 is not matchable. If G 2 is not matchable then there is a set of k nodes in G 2 that has only k-1 neighbors.

k-1 k a b The only way this could fail is if one of the missing nodes is b This is a matchable partition!* Proof of Marriage Theorem Add this in to form G 1, and take G 2 to be everything else. (*Done in lecture on the document cam.)

Suppose that a standard deck of cards is dealt into 13 piles of 4 cards each Then it is possible to select a card from each pile so that the 13 chosen cards contain exactly one card of each rank Example

Proof: Form a bipartite graph as follows: Start with 52 cards on the left and the same 52 cards on the right, connected by 52 edges. Now group the cards on the left into 13 sets according to the given piles. Group the cards on the right into 13 groups according to rank. Let the edges be inherited from the original ones. This bipartite graph is matchable -- k groups on the left have to connect to 4k cards on the right, thus they connect to at least k groups on the right. And thus has a perfect matching.

Generalized Marriage: Hall’s Theorem Let S = {S 1, S 2, …S n } be a set of finite subsets that satisfies: For any subset T of {1,2,…,n} let U = the union of S t for t in T, we have: |U| ≥  |T|. I.E. any k subsets contain at least k elements Then we can choose an element x i from each S i so that {x 1, x 2, …} are all distinct

The proof of Hall’s Theorem is slightly more complicated (but not much) than our proof of the Marriage Theorem. You can find the proof on Wikipedia, or on pages 218 and 219 of Mathematical Thinking by D’Angelo and West.

Here’s What You Need to Know… Minimum Spanning Tree - Definition Counting spanning trees - Matrix-Tree Theorem Kruskal’s Algorithm - Definition - Proof of Correctness Traveling Salesman Problem - Definition - Using MST to get an approximate solution The Marriage Theorem