Maximum Bipartite Matching

Slides:



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

1 Scheduling Crossbar Switches Who do we chose to traverse the switch in the next time slot? N N 11.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
CSE 421 Algorithms Richard Anderson Lecture 23 Network Flow Applications.
The Maximum Network Flow Problem. CSE Network Flows.
Nick McKeown Spring 2012 Maximum Matching Algorithms EE384x Packet Switch Architectures.
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.
MAX FLOW CS302, Spring 2013 David Kauchak. Admin.
Maximum Flow Chapter 26.
9/23/2015ACM-ICPC1 Maximum Flow Problem Source t fg e 42 Target (sink) flow capacity b s c a de 2/3/ actual flow 1/2/ 1/ 2/ 1.Actual flow  capacity.
Lecture 16 Maximum Matching. Incremental Method Transform from a feasible solution to another feasible solution to increase (or decrease) the value of.
Network Flow How to solve maximal flow and minimal cut problems.
CS223 Advanced Data Structures and Algorithms 1 Maximum Flow Neil Tang 3/30/2010.
Graph Algorithms Maximum Flow - Best algorithms [Adapted from R.Solis-Oba]
Algorithm Design and Analysis (ADA)
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Data Structures & Algorithms Network Flow Richard Newman based on book by R. Sedgewick.
NETWORK FLOWS Shruti Aggrawal Preeti Palkar. Requirements 1.Implement the Ford-Fulkerson algorithm for computing network flow in bipartite graphs. 2.For.
Instructor Neelima Gupta Edited by Divya Gaur(39, MCS '09) Thanks to: Bhavya(9), Deepika(10), Deepika Bisht(11) (MCS '09)
Contest Algorithms January 2016 Describe the maxflow problem, explain the Ford-Fulkerson, Edmonds-Karp algorithms. Look at the mincut problem, bipartite.
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Honors Track: Competitive Programming & Problem Solving Push-Relabel Algorithm Claire Claassen.
Ford-Fulkerson Recap.
Maximum Flow Chapter 26.
Network Flow.
The Maximum Network Flow Problem
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
BIPARTITE GRAPHS AND ITS APPLICATIONS
Finding a Path With Largest Smallest Edge
Graph Algorithms Minimum Spanning Tree (Chap 23)
CS4234 Optimiz(s)ation Algorithms
Algorithms and Networks
Maximum Flow - Best algorithms
Algorithm Design and Analysis
Lectures on Network Flows
Richard Anderson Lecture 23 Network Flow
Lecture 22 Network Flow, Part 2
CSCI 3160 Design and Analysis of Algorithms Tutorial 8
Network Flow.
Special Graphs: Modeling and Algorithms
CSE 5311-Class Project Bipartite Matching using Network Flow
Bipartite Matching and Other Graph Algorithms
Maximum Flow Problem flow capacity Actual flow  capacity
Lecture 16 Maximum Matching
Network Flow 2016/04/12.
Instructor: Shengyu Zhang
Edmonds-Karp Algorithm
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
CSE Algorithms Max Flow Problems 11/21/02 CSE Max Flow.
Lecture 10 Network flow Max-flow and Min-cut Ford-Fulkerson method
Richard Anderson Lecture 21 Network Flow
Flow Networks General Characteristics Applications
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
Network Flow CSE 373 Data Structures.
EE5900 Advanced Embedded System For Smart Infrastructure
離散數學 DISCRETE and COMBINATORIAL MATHEMATICS
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
Scheduling Crossbar Switches
Network Flow.
Lecture 21 Network Flow, Part 1
7. Ford-Fulkerson Algorithm with multiple optimal solutions
Dinitz's algorithm for finding a maximum flow in a network.
MAXIMUM flow by Eric Wengert.
Maximum Flow Neil Tang 4/8/2008
Shortest Path Solutions
Lecture 22 Network Flow, Part 2
Special Graphs: Modeling and Algorithms
Network Flow.
Advanced Graph Homer Lee 2013/10/31.
Presentation transcript:

Maximum Bipartite Matching Ralph McDougall 3 February 2018 Comeback tour: 9 March 2019

Definitions A graph is said to be a bipartite graph if it possible to split the nodes into 2 disjoint sets, A and B, such that nodes in set A only have edges leading to nodes in set B A bipartite matching is a bipartite graph such that no 2 edges have a common endpoint The maximum bipartite matching of a bipartite graph is the bipartite matching with the most edges

Example: Bipartite Graph 1 6 2 7 3 8 4 9 5

Example: Bipartite Matching 1 6 2 7 3 8 4 9 5

Example: NOT Bipartite Matching 1 6 2 7 3 8 4 9 5

Example: Maximum Bipartite Matching 1 6 2 7 3 8 4 9 5

Things to note If there are m nodes in set A and n nodes in set B, then the number of edges in the Maximum Bipartite Matching has an upper bound of min(m, n) There can be multiple maximum bipartite matchings

How is this useful? Sample problem: n people are applying for m jobs. Each person can only do 1 job and each job can only be done by 1 person. Given a list of jobs that each person is applying for, find the highest number of jobs that can be filled.

Sample of sample Person Job being applied for Alice Accounting Baking Bob Claire Diving Dave Carpentry

Alternate form of sample of sample Person Job Alice Accounting Bob Baking Claire Carpentry Dave Diving

Maximum Bipartite Matching of alternate form of sample of sample Person Job Alice Accounting Bob Baking Claire Carpentry Dave Diving

Solution to sample Alice does Accounting Bob does Baking Claire does Diving Dave does Carpentry

Network Flow The problem of finding a Maximum Bipartite Matching is a special case of the Network Flow problem A flow network is a weighted directed graph where each edge has a maximum capacity. Flow is sent from a source to a sink. The total flow into a node must be the same as the total flow out except for the source and the sink. The task is to maximise the flow that ends at the sink This problem can be solved with the Edmonds-Karp extension of the Ford-Fulkerson algorithm

Edmonds-Karp Find the path with shortest length from the source to the sink where none of the edges on the path are full (augmenting path) Pass as much flow as possible through that path Repeat until there are no more paths from the source to the sink

Code: Initialisation and input

Code: BFS looking for path

Code: Finding shortest path and flow

Code: Reducing capacity of path edges

Analysis This algorithm runs in O(VE2) time Dinic’s Algorithm can be used to improve this to O(V2E) when the graph is very dense

Back to Maximum Bipartite Matching To turn the Maximum Bipartite Matching into a Network Flow problem we add a source that is connected to all of the nodes in set A and a sink that is connected to all of the nodes in set B All edges are given a weight of 1 From here, the problem of finding the Maximum Bipartite Matching is clearly the same as finding the maximum Network Flow Since Maximum Bipartite Matching is such a special case of Network Flow, there does exist an algorithm than runs in O(VE)

Algorithm Store the graph as an unweighted directed graph Construct a sink and source as before Use a BFS or DFS to find a path from the source to the sink Reverse the direction of each edge on the path Repeat the process of finding a path and reversing until no more paths exist The Maximum Bipartite Matching is the collection of all edges that are reversed

Code: Input and initialisation

Code: BFS

Code: Path Reversal

Code: Output

Analysis The BFS runs in O(E) time The BFS will run at most V times since the number of edges going to the sink is at most V and decreases by 1 every iteration Therefore this algorithm runs in O(VE)