Algorithms and Networks

Slides:



Advertisements
Similar presentations
Maximum flow Main goals of the lecture:
Advertisements

Bart Jansen 1.  Problem definition  Instance: Connected graph G, positive integer k  Question: Is there a spanning tree for G with at least k leaves?
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.
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.
Five Problems CSE 421 Richard Anderson Winter 2009, Lecture 3.
Lectures on Network Flows
Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin /22/2013.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Data Transmission and Base Station Placement for Optimizing Network Lifetime. E. Arkin, V. Polishchuk, A. Efrat, S. Ramasubramanian,V. PolishchukA. EfratS.
Matchings Lecture 3: Jan 18. Bipartite matchings revisited Greedy method doesn’t work (add an edge with both endpoints free)
Graph Colouring Lecture 20: Nov 25.
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.
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,
Fixed Parameter Complexity Algorithms and Networks.
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.
Approximation Algorithms
Data Structures & Algorithms Graphs
Graph Colouring L09: Oct 10. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including the famous.
Matching Algorithms and Networks. Algorithms and Networks: Matching2 This lecture Matching: problem statement and applications Bipartite matching Matching.
Bipartite Matching. Unweighted Bipartite Matching.
1 “Graph theory” Course for the master degree program “Geographic Information Systems” Yulia Burkatovskaya Department of Computer Engineering Associate.
Graph Colouring Lecture 20: Nov 25. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including.
Matching Algorithms and Networks. Algorithms and Networks: Matching2 This lecture Matching: problem statement and applications Bipartite matching Matching.
Assignments and matchings Chapter 12 Presented by Yorai Geffen.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Introduction to Graph Theory
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
An Introduction to Graph Theory
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
Algorithms and Networks
IOI/ACM ICPC Training 4 June 2005.
V15: Max-Flow Min-Cut V15 continues chapter 12 in Gross & Yellen „Graph Theory“ Theorem [Characterization of Maximum Flow] Let f be a flow in a.
Analysis of Algorithms
Lap Chi Lau we will only use slides 4 to 19
Bipartite Matching Lecture 8: Oct 7.
Topics in Algorithms Lap Chi Lau.
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
Lecture 22 Complexity and Reductions
Paths, Trees and Flowers
Lecture 16 Bipartite Matching
Maximum Flow - Best algorithms
Algorithm Design and Analysis
Lectures on Network Flows
Great Theoretical Ideas in Computer Science
The Art Gallery Problem
CSE 421: Introduction to Algorithms
The Art Gallery Problem
Lecture 16 Maximum Matching
Instructor: Shengyu Zhang
Edmonds-Karp Algorithm
Analysis of Algorithms
Richard Anderson Lecture 25 NP-Completeness
Vertex Covers, Matchings, and Independent Sets
Richard Anderson Lecture 30 NP-Completeness
Problem Solving 4.
Flow Networks and Bipartite Matching
Piyush Kumar (Lecture 6: MaxFlow MinCut Applications)
5.4 T-joins and Postman Problems
Algorithms (2IL15) – Lecture 7
EE5900 Advanced Embedded System For Smart Infrastructure
and 6.855J March 6, 2003 Maximum Flows 2
CSE 421, University of Washington, Autumn 2006
Lecture 22 Network Flow, Part 2
Maximum Bipartite Matching
CSE 421 Richard Anderson Autumn 2019, Lecture 3
Presentation transcript:

Algorithms and Networks Matching Algorithms and Networks

Algorithms and Networks: Matching This lecture Matching: problem statement and applications Bipartite matching (recap) Matching in arbitrary undirected graphs: Edmonds algorithm Diversion: generalized tic-tac-toe Algorithms and Networks: Matching

Problem and applications 1 Problem and applications

Algorithms and Networks: Matching Set of edges 𝑀⊆𝐸 such that no vertex is endpoint of more than one edge. Maximal matching No 𝑒∉𝐸 with 𝑀∪ 𝑒 also a matching Maximum matching Matching with 𝑀 as large as possible Perfect matching 𝑀=𝑛/2: each vertex endpoint of edge in 𝑀. Algorithms and Networks: Matching

Algorithms and Networks: Matching Not a maximal matching, Not a maximum matching Not a perfect matching Algorithms and Networks: Matching

Algorithms and Networks: Matching Maximum Matching A maximal matching, A maximum matching Not a perfect matching (Size 4) Algorithms and Networks: Matching

Algorithms and Networks: Matching Maximal Matching A maximal matching, Not a maximum matching Not a perfect matching (Size: 3) Algorithms and Networks: Matching

Algorithms and Networks: Matching Perfect Matching A maximal matching, A maximum matching A perfect matching (Size 4) Algorithms and Networks: Matching

Algorithms and Networks: Matching Cost versions Each edge has cost; look for perfect matching with minimum cost Also polynomial time solvable, but harder Algorithms and Networks: Matching

Algorithms and Networks: Matching Problems Given graph 𝐺, find Maximal matching: easy (greedy algorithm) Maximum matching Polynomial time; not easy. Important easier case: bipartite graphs Perfect matching Special case of maximum matching A theorem for regular bipartite graphs and Schrijver’s algorithm Algorithms and Networks: Matching

Algorithms and Networks: Matching Applications (1) Classroom assignment Scheduling Opponents selection for sport competitions In a chess (or tennis, or …) club, we have n players, that must be paired to play a match, each week. Some players have played already to each other, and we have rating differences. Algorithms and Networks: Matching

Algorithms and Networks: Matching Applications (2) Personnel assignment (bipartite graphs): We have n employees and n jobs. Each employee i has a proficiency index u(i,j) for job j. What assignment maximizes the total proficiency? Our company is international. We have a number of jobs abroad, and a number of employees. For each combination of a job and employee, we have: The information: can this employee do this job? The cost of moving the employee with his family to the new location … Algorithms and Networks: Matching

Application (3): matching moving objects Moving objects, seen at two successive time moments Which object came from where? Algorithms and Networks: Matching

Application (3): matching moving objects Moving objects, seen at two successive time moments Which object came from where? Maybe… Algorithms and Networks: Matching

Bipartite matching (recap) 2 Bipartite matching (recap)

Bipartite graphs: using maximum flow algorithms Finding maximum matching in bipartite graphs: Model as flow problem, and solve it: make sure algorithm finds integral flow. Capacities 1 t s Algorithms and Networks: Matching

Technique works for variants too Minimum cost perfect matching in bipartite graphs Model as min-cost flow problem b-matchings in bipartite graphs Function 𝑏:𝑉→ℕ. Look for set of edges 𝑀, with each 𝑣 endpoint of exactly 𝑏(𝑣) edges in 𝑀. Algorithms and Networks: Matching

Steps by Ford-Fulkerson on the bipartite graph M-augmenting path: unmatched becomes in a flow augmentation step Algorithms and Networks: Matching

A simple non-constructive proof of a well known theorem Theorem. Each regular bipartite graph has a perfect matching. Proof: Construct flow model of G. Set flow of edges from s, or to t to 1, and other edges flow to 1/d. This flow has value n/2, which is optimal. Ford-Fulkerson will find integral flow of value n/2; which corresponds to perfect matching. The literature often gives harder, but constructive proofs. Algorithms and Networks: Matching

3 Edmonds algorithm: matching in (possibly non-bipartite) undirected graphs

A theorem that also works when the graph is not bipartite Theorem. Let 𝑀 be a matching in graph 𝐺. 𝑀 is a maximum matching, if and only if there is no 𝑀-augmenting path. If there is an 𝑀-augmenting path, then 𝑀 is not a maximum matching. Suppose 𝑀 is not a maximum matching. Let 𝑁 be a larger matching. Look at 𝑁⨁𝑀= 𝑁∪𝑀 −(𝑁∩𝑀). Every node in 𝑁⨁𝑀 has degree 0, 1, 2: collection of paths and cycles. All cycles alternatingly have edge from 𝑁 and from 𝑀. There must be a path in 𝑁⨁𝑀 with more edges from 𝑁 than from M: this is an augmenting path. Algorithms and Networks: Matching

Algorithms and Networks: Matching Algorithm of Edmonds Finds maximum matching in a graph in polynomial time Algorithms and Networks: Matching

Algorithms and Networks: Matching Jack Edmonds Photo © Hans Bodlaender Algorithms and Networks: Matching

Algorithms and Networks: Matching Jack Edmonds Photo © Hans Bodlaender Algorithms and Networks: Matching

Algorithms and Networks: Matching Definitions M-alternating walk: (Possibly not simple) path with edges alternating in M, and not M. M-flower M-alternating walk of odd length that starts in an unmatched vertex, and ends as an odd cycle: M-blossom Algorithms and Networks: Matching

Finding an M-augmenting walk Subroutine: given G and M, find an M-augmenting walk: Let X be the set of unmatched vertices. Let Y be the set of vertices adjacent to some vertex in X. Build digraph D = (V,A) with 𝑢,𝑣 there is an 𝑥 with 𝑢,𝑥 ∈𝐸−𝑀 and 𝑥,𝑣 ∈𝑀}. Find a shortest path P from a vertex in X to a vertex in Y in D. Transform P to a path P’ in G Take P”: P, followed by an edge to X. P” is M-alternating walk between two unmatched vertices. Algorithms and Networks: Matching

Finding M-augmenting path or M-flower Look at the path P” we just found. Two cases: P” is a simple path: it is an M-augmenting path P” is not simple. Look to start of P” until the first time a vertex is visited for the second time. This is an M-flower: Cycle-part of walk cannot be of even size, as it then can be removed and we have a shorter walk in D. Algorithms and Networks: Matching

Algorithms and Networks: Matching Algorithmic idea Start with some matching M, and find either M-augmenting path or M-blossom. If we find an M-augmenting path: Augment M, and obtain matching of one larger size; repeat. If we find an M-blossom, we shrink it, and obtain an equivalent smaller problem; recurs. Algorithms and Networks: Matching

Algorithms and Networks: Matching Shrinking M-blossoms Let B be a set of vertices in G. G/B is the graph, obtained from G by contracting B to a single vertex. Contracted Blossom Algorithms and Networks: Matching

Algorithms and Networks: Matching Theorem Theorem: Let B be an M-blossom. Then M has an augmenting path iff M/B has an augmenting path in G/B. Suppose G/B has an M/B-augmenting path P. P does not traverse the vertex representing B: P also M-augmenting path in G. P traverses B: lift to M-augmenting path in G (case analysis). Algorithms and Networks: Matching

Case 1a: P passes through B M/B-Augmenting Path in G/B M-Augmenting Path in G Algorithms and Networks: Matching

Case 1b: P passes through B M/B-Augmenting Path in G/B Q: does path always pass through stem? Algorithms and Networks: Matching

Case 2a: P has B as endpoint Q: when does this case occur? Algorithms and Networks: Matching

Case 2b: P has B as endpoint Algorithms and Networks: Matching

Algorithms and Networks: Matching Converse Flip stem so that B is unmatched to obtain M’. Suppose G has M’-augmenting path P. If P does not intersect B then P also M’/B-augmenting path in G/B. Otherwise, assume P does not start in B, if not reverse P. Since B is free, the part of P until B is an M’/B-augmenting path. Algorithms and Networks: Matching

Algorithms and Networks: Matching Subroutine Given: Graph G, matching M Question: Find M-augmenting path if it exists. Let X be the vertices not endpoint of edge in M. Build D, and test if there is an M-alternating walk P from X to X of positive length. (Using Y, etc.) If no such walk exists: M is maximum matching. If P is a path: output P. If P is not a path: Find M-blossom B on P. Shrink B, and recurse on G/B and M/B. If G/B has no M/B-augmenting path, then M is maximum matching. Otherwise, expand M/B-augmenting path to an M-augmenting path. Algorithms and Networks: Matching

Algorithms and Networks: Matching Edmonds algorithm A maximum matching can be found in O(n2m) time. Start with empty (or any) matching, and repeat improving it with M-augmenting paths until this stops. O(n) iterations. Recursion depth is O(n); work per recursive call O(m). A perfect matching in a graph can be found in O(n2m) time, if it exists. Algorithms and Networks: Matching

Algorithms and Networks: Matching Improvements Better analysis and data structures gives O(n3) algorithm. Faster is possible: O(n1/2 m) time. Minimum cost matchings with more complicated structural ideas. Algorithms and Networks: Matching

Diversion: multidimensional tic-tac-toe 5 Diversion: multidimensional tic-tac-toe

Trivial drawing strategies in multidimensional tic-tac-toe Generalizations More dimensions Larger board size Who has a winning strategy? Either first player has winning strategy, or second player has drawing strategy Algorithms and Networks: Matching

Trivial drawing strategy If lines are long enough: pairing of squares such that each line has a pair If player 1 plays in a pair, then player 2 plays to other square in pair v i a f j b h u c g d e Algorithms and Networks: Matching

Trivial drawing strategies and generalized matchings Bipartite graph: line-vertices and square-vertices; edge when square is part of line Look for set of edges M, such that: Each line-vertex is incident to two edges in M Each square-vertex is incident to at most one edge in M There exists such a set of edges M, if and only if there is a trivial drawing strategy (of the described type). Algorithms and Networks: Matching

Algorithms and Networks: Matching Consequences Testing if trivial drawing strategy exists and finding one if so can be done efficiently (flow algorithm). n by n by …by n tic-tac-toe (d-dimensional) has a trivial drawing strategy if n is at least 3𝑑−1 A square belongs to at most 3𝑑−1 lines. So, if n is at least 3𝑑−1 then line-square graph has an edge coloring with n colors. Let M be the set of edges with colors 1 and 2. Algorithms and Networks: Matching

6 Conclusions

Algorithms and Networks: Matching Conclusion Many applications of matching! Often bipartite… Algorithms for finding matchings: Bipartite: flow models Bipartite, regular: Schrijver (See course Algorithms for decision support) General: with M-augmenting paths and blossom-shrinking Minimum cost matching can also be solved in polynomial time: more complex algorithm Min cost matching on bipartite graphs is solved using min cost flow Algorithms and Networks: Matching