Maximum Flow - Best algorithms

Slides:



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

CSE 211 Discrete Mathematics
22C:19 Discrete Math Graphs Fall 2014 Sukumar Ghosh.
Bipartite Matching, Extremal Problems, Matrix Tree Theorem.
Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.
Great Theoretical Ideas in Computer Science for Some.
1 Discrete Structures & Algorithms Graphs and Trees: III EECE 320.
Lecture 24 Coping with NPC and Unsolvable problems. When a problem is unsolvable, that's generally very bad news: it means there is no general algorithm.
Algorithms and Networks
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Approximation Algorithms: Combinatorial Approaches Lecture 13: March 2.
Chapter 26 of CLSR Bipartite Matching By Dr. M. Sakalli, Sources: Levitin and many other CSE, Marmara Univ. May/2009.
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,
Week 11 - Friday.  What did we talk about last time?  Exam 2 post mortem  Cycle detection  Connectivity.
Chapter 10: Iterative Improvement Simplex Method The Design and Analysis of Algorithms.
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.
All Pair Shortest Path IOI/ACM ICPC Training June 2004.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Bipartite Matching. Unweighted Bipartite Matching.
Network Flows Chun-Ta, Yu Graduate Institute Information Management Dept. National Taiwan University.
Graph Algorithms Maximum Flow - Best algorithms [Adapted from R.Solis-Oba]
Prof. Swarat Chaudhuri COMP 382: Reasoning about Algorithms Fall 2015.
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
Indian Institute of Technology Kharagpur PALLAB DASGUPTA Graph Theory: Matchings and Factors Pallab Dasgupta, Professor, Dept. of Computer Sc. and Engineering,
IOI/ACM ICPC Training 4 June 2005.
Cybernetica AS & Tartu University
Chapter 10 Iterative Improvement
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
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
CS4234 Optimiz(s)ation Algorithms
Algorithms for hard problems
Paths, Trees and Flowers
Algorithms and Networks
Lectures on Network Flows
Maximum Flow 9/13/2018 6:12 PM Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.
Great Theoretical Ideas in Computer Science
Special Graphs: Modeling and Algorithms
Chapter 5. Optimal Matchings
Shortest Path Problems
Various Graph Algorithms
Bipartite Matching and Other Graph Algorithms
Computability and Complexity
Minimal Spanning Trees
1.3 Modeling with exponentially many constr.
Discrete Mathematics for Computer Science
ICS 353: Design and Analysis of Algorithms
Instructor: Shengyu Zhang
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.
Analysis of Algorithms
Minimum-Cost Spanning Tree
Minimum-Cost Spanning Tree
CS 583 Analysis of Algorithms
Shortest Path Problems
Richard Anderson Lecture 30 NP-Completeness
Problem Solving 4.
1.3 Modeling with exponentially many constr.
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
Lecture 14 Shortest Path (cont’d) Minimum Spanning Tree
Chapter 6 Network Flow Models.
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
Text Book: Introduction to algorithms By C L R S
Piyush Kumar (Lecture 3: Stable Marriage)
Winter 2019 Lecture 11 Minimum Spanning Trees (Part II)
Special Graphs: Modeling and Algorithms
Lecture 13 Shortest Path (cont’d) Minimum Spanning Tree
Maximum Bipartite Matching
Week 10 - Wednesday CS221.
Autumn 2019 Lecture 11 Minimum Spanning Trees (Part II)
Presentation transcript:

Maximum Flow - Best algorithms [Adapted from R.Solis-Oba]

Graph matching problem Edmonds algorithm: (|V|1/2 |E|) (“easy bond” – (|V|4)) Mucha-Sankowski algorithm: (|V|2.376) [Adapted from R.Diestel]

Bipartite Matching [Adapted from Z.Hu]

Bipartite Matching [Adapted from Z.Hu]

Bipartite Matching Problem Find maximum number of disjoint edges between vertices from two disjoint sets. 2 pairs in the 1st case and 3 in the 2nd. Can we find more?

Bipartite Matching - Idea [Adapted from Z.Hu]

Bipartite Matching - Idea [Adapted from Z.Hu]

Bipartite Matching [Adapted from Z.Hu]

Bipartite Matching [Adapted from Z.Hu]

Bipartite Matching - Complexity The size of network (values |V| and |E|) are of the same order as in initial graph. Edmods-Karp: T(V,E) = O(V E2) Can we do better?

Bipartite Matching - Complexity Note, that | f*|  |V|. Thus (independently from how we chose augmenting paths) T(V,E) = O(| f*| E) = O(V E). Of course, this holds also for Edmods-Karp algorithm. Can we do better?

Bipartite Matching - Complexity Theorem Let M be any matching, and let a maximum matching have |M| + k edges. Then M has at least k disjoint augmenting paths. Proof M - matching M' - a maximum matching Consider M and M' together. This is a graph (actually, multigraph) with vertex degree at most 2. Divide this graph in connected components.

Bipartite Matching - Complexity Consider M and M' together and divide this graph in connected components. There are 3 possibilities: A non-augmenting path (or possibly a closed circuit) with an equal number of edges from M and M'. An augmenting path where the first and the last edge belongs to M'. A diminishing path which begins and ends with an edge from M. Essentially, one should notice that all components will consist of edges alternating from M and M'.

Bipartite Matching - Complexity There is one more edge from M' than M in an augmenting path, and one edge less in a diminishing path. Hence (# of augmenting paths) − (# of diminishing paths) = k, and so there must be at least k augmenting paths. Augmenting path - starts and ends with edges from M'. Corresponds to augmenting path in flow graph for M. Diminishing path - starts and ends with edges from M. Corresponds to augmenting path in flow graph for M'.

Bipartite Matching - Complexity Theorem Let M be any matching, and let a maximum matching have |M| + k edges. Then M has at least k disjoint augmenting paths. Corollary If k edges can be added to the matching then there is an augmenting path of length at most |V| /k. If there are no augmenting paths of length ≤ |V|1/2, then there are at most |V|1/2 augmenting paths remaining before the maximum matching is found.

Bipartite Matching - Complexity The problem is to find |V| augmenting paths. If we look for each of them seperately, each such step requires time |E|. Can we join some steps? Start with M and add all shortest disjoint augmenting paths that can be found using BFS. Lets assume, the length of shortest paths is d and the resulting matching is M'.

Bipartite Matching - Complexity d Do BFS up to the depth d. Select at this depth all vertices from "sink side" from which there is path to t. Then, use just greedy strategy to select as many disjoint augmenting paths as possible (start at selected vertices and backtrack, until vertex s is reached, or a vertex already in use and distinct from s is found). Each such step will require time O(d ·(# of paths) + |E|).

Bipartite Matching - Complexity Start with M and add all shortest disjoint augmenting paths that can be found using BFS. Lets assume, the length of shortest paths is d and the resulting matching is M'. Proposition The length of shortest augmenting path in M' is at least d+1. Proof First, note that for sink-side vertices there is at most one outgoing edge for each vertex. Similarly, for source-side vertices there is at most one incoming edge for each vertex. (We don't count edges connecting with s or t).

Bipartite Matching - Complexity Assume there is an augmenting path in M' of length smaller than d+1. It must intersect with at least one of augmenting paths selected in previous step (otherwise, it should be selected by greedy strategy already in previous step). If intersection vertex is on source-side, path shares the previous edge with an augmenting path from previous step. If intersection vertex is on sink-side, path shares the next edge with an augmenting path from previous step. In any case, there will be a shared adge between this path and one used in previous step.

Bipartite Matching - Complexity In any case, there will be a shared edge between this path and one used in previous step. x x+1 x'  1 x' x x+1  x' x+2  x' + 1 We should have: x'+1  x' and x+2  x' + 1. Taking d = x+2 and d'= x'1, we get d  x' > x'1  d'.

Bipartite Matching - Complexity The problem is to find |V| augmenting paths, if we look for each of them separately, each such step requires time |E|. Can we join some steps? Idea: Run BFS looking for paths with length d = 1... |V|1/2. Time for each step: O(d ·(# of paths) + |E|) Total time: O(|V|1/2·|V| + |E|·|V|1/2) = O(|E|·|V|1/2) Some paths could remain, but at most |V|1/2. To find them requires time at most O(|E|·|V|1/2). Time complexity for bipartite matching: O(|E|·|V|1/2).

”Stable mariage” problem Given bipartite graph with edge weights w: E R. Problem 1 Find a matching, which doesn’t contain two edges (a,a’) and (b,b’), such that w(a,a’)<w(a,b’) and w(b,b’)<w(b,a’). It is commonly stated as (ok this is slightly different version of the problem): Given n men and n women, where each person has ranked all members of the opposite sex with a unique number between 1 and n in order of preference, marry the men and women together such that there are no two people of opposite sex who would both rather have each other than their current partners. If there are no such people, all the marriages are "stable".

”Stable mariage” problem Trivial “greedy search” approach: While there is a blocking pair Do Switch the blocking pair Depending from the exact formulation of the problem this strategy can be either comparatively non-efficient or even not terminate at all.

”Stable mariage” problem Gale-Shapley algorithm (1962) Fix some ordering on the men Repeat until everyone is matched Let X be the first unmatched man in the ordering Find woman Y such that Y is the most desirable woman in X’s list such that Y is unmatched, or Y is currently matched to a Z and X is more preferable to Y than Z. Match X and Y; possible this turns Z to be unmatched The algorithm finds a stable matching in O(n2) time

”Stable mariage” problem Gale-Shapley algorithm Once a woman is matched, she stays matched (her partner can change). When the partner of a woman changes, this is to a more preferable partner for her: at most n – 1 times. Every step, either an unmatched woman becomes matched, or a matched woman changes partner: at most n2 steps.

”Stable mariage” problem Gale-Shapley algorithm Optimality (the marriages are stable): Let Alice be a woman and Bob be a man who are both engaged, but not to each other. Upon completion of the algorithm, it is not possible for both Alice and Bob to prefer each other over their current partners. If Bob prefers Alice to his current partner, he must have proposed to Alice before he proposed to his current partner. If Alice accepted his proposal, yet is not married to him at the end, she must have dumped him for someone she likes more, and therefore doesn't like Bob more than her current partner. If Alice rejected his proposal, she was already with someone she liked more than Bob.

Weighted Bipartite Matching Given bipartite graph with edge weights w: E R. Problem 1 Find a matching with minimal sum of edge weights. Problem 2 Find a matching with minimal sum of edge weights from the set of all matchings with maximal cardinality (maximum matchings). If we have an algorithm that in i-th step produces the cheapest matching with cardinality i, we effectively can deal with both of these problems...

Weighted Bipartite Matching Which flow graph should we use? Add source and sink vertices s and t as in non-weighted case, however: - use unlimited capacities for edges connecting s and t; - when looking for augmenting paths do not use edges connecting s or t with a vertex that has already been included in a matching. So actually the weighted bipartite matching problem can not be reduced to finding of maximal flow, but there is some similarity of these algorithms.

Weighted Bipartite Matching Theorem Let M be a cheapest matching with k edges. A cheapest matching with k + 1 edges can be obtained by augmenting M with the cheapest augmenting path. Proof M' - a cheapest matching with k + 1 edges. Consider M M' . As before, we get 3 types of connected components:

Weighted Bipartite Matching Consider all 3 types of connected components of M M': Non-augmenting paths with even number of edges. Augmenting paths with one edge more from M' than M. Diminishing paths with one edge more from M'than M'. In a non-augmenting path, the total weight of edges in M must be equal to the total weight of edges in M'. Otherwise one of the matchings could be made cheaper by replacing the edges in the path by those in the other matching.

Weighted Bipartite Matching The number of augmenting paths is one greater than the number of diminishing paths. Consider a pair consisting of one augmenting path and one diminishing path. The total weight of the edges in both paths that belong to M must equal the weight of the edges in M' in the two paths. Otherwise we could switch the edges in M and M' and obtain a cheaper matching of size k or k + 1.

Weighted Bipartite Matching We have to show that there is a cheapest matching with k + 1 edges that can be obtained by augmenting M with a cheapest augmenting path. Modify M' as follows: - in components of type 1, replace all M' edges with M edges (except for two vertex components, i.e. when these matchings coincide). - for each augmenting-diminishing path pair, replace all M' edges with M edges. Resulting matching M'' will be a cheapest matching with k + 1 edges and obtainable by augmenting M with a cheapest

Weighted Bipartite Matching - Complexity We can solve the problem of finding the cheapest maximum matching, in the same way than finding maximum non-weighted matching, except, that we have to look for the cheapest augmenting paths, instead of any. Up to |V| steps, each of which takes time O(|V||E|) (using Bellman-Ford). Total time complexity: O(|V|2|E|). There is a historical Hungarian method (Harold Kuhn, 1955) also with running time O(|V|2|E|). Time can be reduced to O(|V|2log |V| + |V||E|) (using reweighting and Dijkstra’s algorithm).

Travelling Salesman Problem TSP (Travelling Salesman Problem) For a given undirected weighted graph, find a minimal weight cycle containing all the vertices. Known to be NP-hard.

Travelling Salesman Problem TSP tour of Sweden 24978 cities length 72500 km solved in 2004

Branch and bound algorithms - generate each potential solution just once - try to find some rules that allows to cut some branches of serach tree

Minimal weight cycle cover TSP (Travelling Salesman Problem) For a given undirected weighted graph, find a minimal weight cycle containing all the vertices. Cheapest second degree graph For a given undirected weighted graph, find a set of cycles with minimal total weight containing all the vertices. Heuristic methods for TSP: In each step chose the extension of a partial path with minimal weight cycle cover for remaining part of the graph.