1 “Graph theory” Course for the master degree program “Geographic Information Systems” Yulia Burkatovskaya Department of Computer Engineering Associate.

Slides:



Advertisements
Similar presentations
Paths, Trees and Flowers
Advertisements

Min-Max Relations, Hall’s Theorem, and Matching-Algorithms Graphs & Algorithms Lecture 5 TexPoint fonts used in EMF. Read the TexPoint manual before you.
Single Source Shortest Paths
C&O 355 Lecture 23 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A A A A A A A A.
Bipartite Matching, Extremal Problems, Matrix Tree Theorem.
Totally Unimodular Matrices
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
Algorithms and Networks
Breadth-First Search of Graphs Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
Combinatorial Algorithms
1 Weighted Bipartite Matching Lecture 4: Jan Weighted Bipartite Matching Given a weighted bipartite graph, find a matching with maximum total weight.
Lectures on Network Flows
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.
Totally Unimodular Matrices Lecture 11: Feb 23 Simplex Algorithm Elliposid Algorithm.
Primal Dual Method Lecture 20: March 28 primaldual restricted primal restricted dual y z found x, succeed! Construct a better dual.
Matchings Lecture 3: Jan 18. Bipartite matchings revisited Greedy method doesn’t work (add an edge with both endpoints free)
A general approximation technique for constrained forest problems Michael X. Goemans & David P. Williamson Presented by: Yonatan Elhanani & Yuval Cohen.
Maximum Bipartite Matching
Maximum Flows Lecture 4: Jan 19. Network transmission Given a directed graph G A source node s A sink node t Goal: To send as much information from s.
1 Bipartite Matching Lecture 3: Jan Bipartite Matching A graph is bipartite if its vertex set can be partitioned into two subsets A and B so that.
CSE 421 Algorithms Richard Anderson Lecture 4. What does it mean for an algorithm to be efficient?
Minimum Cost Flow Lecture 5: Jan 25. Problems Recap Bipartite matchings General matchings Maximum flows Stable matchings Shortest paths Minimum spanning.
Randomness in Computation and Communication Part 1: Randomized algorithms Lap Chi Lau CSE CUHK.
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
C&O 355 Mathematical Programming Fall 2010 Lecture 17 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA A.
Advanced Algorithms Piyush Kumar (Lecture 5: Weighted Matching) Welcome to COT5405 Based on Kevin Wayne’s slides.
Hon Wai Leong, NUS (CS6234, Spring 2009) Page 1 Copyright © 2009 by Leong Hon Wai CS6234 Lecture 1 -- (14-Jan-09) “Introduction”  Combinatorial Optimization.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
CSE, IIT KGP Matchings and Factors. CSE, IIT KGP Matchings A matching of size k in a graph G is a set of k pairwise disjoint edges.A matching of size.
Analysis of Algorithms Uri Zwick April 2014 Maximum matching 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAA.
Design Techniques for Approximation Algorithms and Approximation Classes.
Approximating Minimum Bounded Degree Spanning Tree (MBDST) Mohit Singh and Lap Chi Lau “Approximating Minimum Bounded DegreeApproximating Minimum Bounded.
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Hon Wai Leong, NUS (CS6234, Spring 2009) Page 1 Copyright © 2009 by Leong Hon Wai CS6234: Lecture 4  Linear Programming  LP and Simplex Algorithm [PS82]-Ch2.
Graph Colouring L09: Oct 10. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including the famous.
3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Matching Algorithms and Networks. Algorithms and Networks: Matching2 This lecture Matching: problem statement and applications Bipartite matching Matching.
Matching Algorithms and Networks. Algorithms and Networks: Matching2 This lecture Matching: problem statement and applications Bipartite matching Matching.
Hon Wai Leong, NUS (CS6234, Spring 2009) Page 1 Copyright © 2009 by Leong Hon Wai CS6234: Lecture 4  Linear Programming  LP and Simplex Algorithm [PS82]-Ch2.
Matching Lecture 19: Nov 23.
Graph Algorithms Maximum Flow - Best algorithms [Adapted from R.Solis-Oba]
10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 21 Network.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
CSE 421 Algorithms Richard Anderson Winter 2009 Lecture 5.
Introduction to Graph Theory
C&O 355 Lecture 19 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A A A A A A A A.
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
Approximation Algorithms by bounding the OPT Instructor Neelima Gupta
Matching and Factors Matchings and Covers. Definitions: A matching M in a graph G is a set of non loop edges with no shared endpoints. G M.
Indian Institute of Technology Kharagpur PALLAB DASGUPTA Graph Theory: Matchings and Factors Pallab Dasgupta, Professor, Dept. of Computer Sc. and Engineering,
Lap Chi Lau we will only use slides 4 to 19
Bipartite Matching Lecture 8: Oct 7.
Topics in Algorithms Lap Chi Lau.
Paths, Trees and Flowers
Algorithms and Networks
Maximum Flow - Best algorithms
Algorithm Design and Analysis
Lectures on Network Flows
Chapter 5. Optimal Matchings
Instructor: Shengyu Zhang
Analysis of Algorithms
Problem Solving 4.
Algorithms (2IL15) – Lecture 7
Richard Anderson Lecture 5 Graph Theory
Presentation transcript:

1 “Graph theory” Course for the master degree program “Geographic Information Systems” Yulia Burkatovskaya Department of Computer Engineering Associate professor

2 Bipartite Matching

3 A graph is bipartite if its vertex set can be partitioned into two subsets A and B so that each edge has one endpoint in A and the other endpoint in B. A matching M is a subset of edges so that every vertex has degree at most one in M. A B

4 The bipartite matching problem: Find a matching with the maximum number of edges. Maximum Matching A perfect matching is a matching in which every vertex is matched. The perfect matching problem: Is there a perfect matching?

5 Greedy method? (add an edge with both endpoints unmatched) First Try

6 Key Questions How to tell if a graph does not have a (perfect) matching? How to determine the size of a maximum matching? How to find a maximum matching efficiently?

7 Hall’s Theorem [1935]: A bipartite graph G=(A,B;E) has a matching that “saturates” A if and only if |N(S)| >= |S| for every subset S of A. S N(S) Existence of Perfect Matching

8 König [1931]: In a bipartite graph, the size of a maximum matching is equal to the size of a minimum vertex cover. What is a good upper bound on the size of a maximum matching? Min-max theorem Implies Hall’s theorem. Bound for Maximum Matching König [1931]: In a bipartite graph, the size of a maximum matching is equal to the size of a minimum vertex cover.

9 Any idea to find a larger matching? Algorithmic Idea?

10 Given a matching M, an M-alternating path is a path that alternates between edges in M and edges not in M. An M-alternating path whose endpoints are unmatched by M is an M-augmenting path. Augmenting Path

11 What if there is no more M-augmenting path? Prove the contrapositive: A bigger matching  an M-augmenting path 1. Consider 2. Every vertex in has degree at most 2 3. A component in is an even cycle or a path 4. Since, an M-augmenting path! If there is no M-augmenting path, then M is maximum! Optimality Condition

12 Algorithm Key: M is maximum  no M-augmenting path How to find efficiently?

13 Finding M-augmenting paths Orient the edges (edges in M go up, others go down) An M-augmenting path  a directed path between two unmatched vertices

14 Complexity At most n iterations An augmenting path in time by a DFS or a BFS Total running time

15 Hall’s Theorem [1935]: A bipartite graph G=(A,B;E) has a matching that “saturates” A if and only if |N(S)| >= |S| for every subset S of A. König [1931]: In a bipartite graph, the size of a maximum matching is equal to the size of a minimum vertex cover. Idea: consider why the algorithm got stuck… Minimum Vertex Cover

16 Observation: Many short and disjoint augmenting paths. Idea: Find augmenting paths simultaneously in one search. Faster Algorithms

17 Application of Bipartite Matching Jerry Marking DarekTomIsaac TutorialsSolutions Newsgroup Job Assignment Problem: Each person is willing to do a subset of jobs. Can you find an assignment so that all jobs are taken care of?

18 Application of Bipartite Matching With Hall’s theorem, now you can determine exactly when a partial chessboard can be filled with dominos.

19 Application of Bipartite Matching Latin Square: a nxn square, the goal is to fill the square with numbers from 1 to n so that: Each row contains every number from 1 to n. Each column contains every number from 1 to n.

20 Application of Bipartite Matching Now suppose you are given a partial Latin Square. Can you always extend it to a Latin Square? With Hall’s theorem, you can prove that the answer is yes.

Hon Wai Leong, NUS (CS6234, Spring 2009) Page 21 Copyright © 2009 by Leong Hon Wai Matching in Graph  Matching in Bipartite Graph  Matching in General Graphs  Weighted Matching in Bipartite Graph  Additional topics: u Reading/Presentation by students Lecture notes modified from those by Lap Chi LAU, CUHK.

22 General Matching

23 General Matching Given a graph (not necessarily bipartite), find a matching with maximum total weight. unweighted (cardinality) version: a matching with maximum number of edges

24 Today’s Plan Min-max theorems [no proofs] Polynomial time algorithm Chinese postman [skip] Follow the same structure for bipartite matching.

25 Characterization of Perfect Matching Hall’s Theorem [1935]: A bipartite graph G=(A,B;E) has a matching that “saturates” A if and only if |N(S)| >= |S| for every subset S of A. Tutte’s Theorem [1947]: A graph has a perfect matching if and only if o(G-S) <= |S| for every subset S of V.

26 Min-Max Theorem Tutte-Berge formula [1958]: The size of a maximum matching = König [1931]: In a bipartite graph, the size of a maximum matching is equal to the size of a minimum vertex cover.

27 Given a matching M, an M-alternating path is a path that alternates between edges in M and edges not in M. An M-alternating path whose endpoints are unmatched by M is an M-augmenting path. Augmenting Path? Works for general graphs.

28 What if there is no more M-augmenting path? Prove the contrapositive: A bigger matching  an M-augmenting path 1. Consider 2. Every vertex in has degree at most 2 3. A component in is an even cycle or a path 4. Since, an M-augmenting path! If there is no M-augmenting path, then M is maximum? Optimality Condition?

29 Algorithm? Key: M is maximum  no M-augmenting path How to find efficiently?

30 Finding Augmenting Path in Bipartite Graphs Orient the edges (edges in M go up, others go down) edges in M having positive weights, otherwise negative weights In a bipartite graph, an M-augmenting path corresponds to a directed path.

31 Finding M-augmenting paths in General Graphs Don’t know how to orient the edges so that: an M-augmenting path  a directed path between two free vertices …alternating path segment (before & after augmentation): …  v1  v2  v3  v4  v5  v6  v7  … Repeated Vertex !!!

32 No repeated vertices. So? Just find an alternating path without repeated vertices?! Either we may exclude some possibilities, Or we need to trace the path…

33 Blossom Note: When performing search for M-augmenting path, we may encounter M-blossom!

34 Shrink the blossoms! Key idea (Edmonds 1965) General matching algorithm

35 Key Lemma (Edmonds) M is a maximum matching in G  M/C is a maximum matching in G/C Key: M is maximum  no M-augmenting path  an M-augmenting path in G   an M/C-augmenting path in G/C

36  an M/C-augmenting path   an M-augmenting path Note: One of the two paths around the blossom will be the correct one.

37  an M-augmenting path   an M/C-augmenting path Note: Many cases to be considered (see [PS82]-Ch10.) Case 0: M-augmenting path p does not “intersect” M-blossom C Case 1: p enters/leaves M-blossom C with matched edge

38  an M-augmenting path   an M/C-augmenting path Case 2: p enters M-blossom C with free edge 2(a): p leaves via matched edge (1 st example [in black]) 2(b): p leaves C with free edge (2 nd example [in red])

39 Algorithm Key: M is maximum  no M-augmenting path How to find efficiently?

40 Finding an M-augmenting path Find an alternating walk between two free vertices. This can be done in linear time by a DFS or a BFS. Either an M-augmenting path or a blossom can be found. If a blossom is found, shrink it, and (recursively) find an M/C-augmenting path P in G/C, and then expand P to an M-augmenting path in G.

41 Complexity At most n augmentations. Each augmentation does at most n contractions. An alternating walk can be found in O(m) time. Total running time is O(mn 2 ).

42 Historical Remarks In his famous paper “paths, trees, and flowers”, Jack Edmonds: Introduced the notion of a “good” algorithm. Edmonds solved weighted general matching, primal dual. Linear programming description, a breakthrough in polyhedral combinatorics. An O(n3) algorithm by Pape and Conradt, 1980 Ref: [SDK83] Syslo, Deo, Kowalik, Prentice-Hall, 1983 Discrete Optimization Algorithms, Ch 3.7

43 Tutte-Berge formula [1958]: The size of a maximum matching = Proving Min-Max Theorem Comments by LeongHW: Skip next few slides on mainly combinatorial results… (Anyone wants to do this for reading assignment?)

44 M-alternating forest Larger forest M-augmenting patha blossom We make progress in any of the above cases.

45 M-alternating forest Otherwise we find the set in Tutte-Berge formula.

46 Edmonds-Gallai Decomposition Can be obtained from M-alternating forest. Contains a lot of information about matching.

47 Chinese Postman Given an undirected graph, a vertex v, a length l(e) on each edge e, find a shortest tour to visit every edge once and come back to v. Visit every edge exactly once if Eulerian. Otherwise, find a minimum weighted perfect matching between odd vertices.

48 Tutte Matrix Skew symmetric matrix, a(u,v)=x(e) and a(v,u)=-x(e) Full rank  perfect matching Randomized algorithm

Hon Wai Leong, NUS (CS6234, Spring 2009) Page 49 Copyright © 2009 by Leong Hon Wai CS6234:  Matching in Graph  Matching in Bipartite Graph  Matching in General Graphs  Weighted Matching in Bipartite Graph  Additional topics: u Reading/Presentation by students Lecture notes modified from those by Lap Chi LAU, CUHK.

50 Weighted Bipartite Matching

51 Weighted Bipartite Matching Given a weighted bipartite graph, find a matching with maximum total weight. Not necessarily a maximum size matching. A B Wlog, assume perfect matching on complete bipartite graph; (add fictitious edges with weights 0)

52 First Algorithm How to know if a given matching M is optimal? Idea: Imagine there is a larger matching M* and consider the union of M and M* Find maximum weight perfect matching

53 First Algorithm Orient the edges (edges in M go up, others go down) edges in M having positive weights, otherwise negative weights Then M is maximum if and only if there is no negative cycles

54 First Algorithm Key: M is maximum  no negative cycle How to find efficiently?

55 Complexity At most nW iterations A negative cycle in O(n 3 ) time by Floyd Warshall Total running time O(n 4 W) Can choose minimum mean cycle to avoid W

56 Comments by LeongHW: Skip next few slides on Augmenting Path Algorithm (Anyone wants to do this for reading assignment?)

57 Augmenting Path Algorithm Orient the edges (edges in M go up, others go down) edges in M having positive weights, otherwise negative weights Find a shortest path M-augmenting path at each step

58 Augmenting Path Algorithm Theorem: Each matching is an optimal k-matching. Let the current matching be M Let the shortest M-augmenting path be P Let N be a matching of size |M|+1

59 Complexity At most n iterations A shortest path in O(nm) time by Bellman Ford Total running time O(n 2 m) Can be speeded up by using Dijkstra: O(m + n log n) Total running time O(nm + n 2 log n) Kuhn (based on proof by Egervary) — Hungarian method

60 Primal Dual Algorithm What is an upper bound of maximum weighted matching? What is a generalization of minimum vertex cover? weighted vertex cover: Minimum weighted vertex cover  Maximum weighted matching

61 Primal Dual Algorithm Minimum weighted vertex cover  Maximum weighted matching Primal Dual (Overview) Maintain a weighted matching M Maintain a weighted vertex cover y Either increase M or decrease y until they are equal.

62 Primal Dual Algorithm Minimum weighted vertex cover  Maximum weighted matching 1.Consider the subgraph formed by tight edges (the equality subgraph). 2.If there is a tight perfect matching, done. 3.Otherwise, there is a vertex cover. 4.Decrease weighted cover to create more tight edges, and repeat. Detailed algorithm will be covered later (after LP Primal-Dual algorithms)

63 Complexity Augment at most n times, each O(m) Decrease weighted cover at most m times, each O(m) Total running time: O(m 2 ) = O(n 4 ) Egervary, Hungarian method History: The algorithm was developed by Kuhn who based it on work of Egervary [1931], (“latent work of D. Konig and J. Egervary”) and was given the name “Hungarian method”. See [Schr02]-Ch17 for more details.

64 Quick Summary 1.First algorithm, negative cycle, useful idea to consider symmetric difference 2.Augmenting path algorithm, useful algorithmic technique 3.Primal dual algorithm, a very general framework 1.Why primal dual? 2.How to come up with weighted vertex cover? 3.Reduction from weighted case to unweighted case

65 Faster Algorithms

66 Application of Bipartite Matching Jerry Marking DarekTomIsaac TutorialsSolutions Newsgroup Job Assignment Problem: Each person is willing to do a subset of jobs. Can you find an assignment so that all jobs are taken care of? Ad-auction, Google, online matching Fingerprint matching