Download presentation
Presentation is loading. Please wait.
1
Maximum Flow - Best algorithms
[Adapted from R.Solis-Oba]
2
Graph matching problem
Edmonds algorithm: (|V|1/2 |E|) (“easy bond” – (|V|4)) Mucha-Sankowski algorithm: (|V|2.376) [Adapted from R.Diestel]
3
Bipartite Matching [Adapted from Z.Hu]
4
Bipartite Matching [Adapted from Z.Hu]
5
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?
6
Bipartite Matching - Idea
[Adapted from Z.Hu]
7
Bipartite Matching - Idea
[Adapted from Z.Hu]
8
Bipartite Matching [Adapted from Z.Hu]
9
Bipartite Matching [Adapted from Z.Hu]
10
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?
11
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?
12
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.
13
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'.
14
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'.
15
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.
16
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'.
17
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|).
18
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).
19
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.
20
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' 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'.
21
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).
22
”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".
23
”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.
24
”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
25
”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.
26
”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.
27
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...
28
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.
29
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:
30
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.
31
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.
32
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
33
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).
34
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.
35
Travelling Salesman Problem
TSP tour of Sweden 24978 cities length km solved in 2004
36
Branch and bound algorithms
- generate each potential solution just once - try to find some rules that allows to cut some branches of serach tree
37
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.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.