Download presentation
Presentation is loading. Please wait.
Published byNorman Preston Modified over 9 years ago
1
Network Flows Chun-Ta, Yu Graduate Institute Information Management Dept. National Taiwan University
2
Chapter 12 ASSIGHMENTS AND MATCHINGS
3
Outline Introduction Bipartite Cardinality Matching Problem Bipartite Weighted Matching Problem Stable Marriage Problem Nonbipartite Cardinality Matching Problem
4
Introduction Bipartite matching problem 1.The cardinality problem 2.The weighted problem Stable marriage problem Nonbipartite matching problem
5
Bipartite Cardinality Matching Problem Transform this problem into a maximum flow problem in a simple network –Each arc has a unit capacity and each node has an indegree of at most 1 or an outdegree of at most 1 –Introduce a source node s and a sink node t Solving this problem at worst-case
6
Bipartite Cardinality Matching Problem
7
Bipartite Weighted Matching Problem Assignment problem Given a weighted bipartite network
8
Bipartite Weighted Matching Problem The assignment problem can be viewed as adaptation of algorithm for the minimum cost flow problem Four algorithm to solve : 1.Successive Shortest Path Algorithm 2.Hungarian Algorithm 3.Relaxation Algorithm 4.Cost Scaling Algorithm
9
Successive Shortest Path Algorithm Discuss in section 9.7 Augment 1 unit flow in every iteration S( n,m,C) n 1 =|N 1 | Let S( n,m,C) denote the time needed to solve a shortest path problem with nonnegative arc lengths and n 1 =|N 1 | O(n 1 S( n,m,C)) The algorithm would terminate within n 1 iterations and would require O(n 1 S( n,m,C))
10
Hungarian Algorithm Discuss in section 9.7, primal-dual algorithm s* t*. s* With a single supply node s* and a single demand node t*.At every iteration,the primal-dual algorithm computes shortest path distance from s* to all other nodes n 1 O(n 1 S( n,m,C)) The algorithm would terminate within n 1 iterations and would require O(n 1 S( n,m,C))
11
Relaxation Algorithm Closely related to the successive shortest path algorithm Relax the constraint N 2 N 1 thus allowing any node in N 2 to be assigned to more than one node in N 1 O(n 1 S( n,m,C)) Overall running time O(n 1 S( n,m,C))
12
Stable Marriage Problem A certain community consists of n men and n women. Each person ranks those of the opposite sex in accordance with his or her preferences for a spouse. Unstable – if man-woman are not married to each other but prefer each other to their current spouses O(n 2 ) For any set of rankings, we can always find a stable matching in O(n 2 ) time
13
Stable Marriage Problem n x n The input to the stable marriage problem consists of two n x n matrices. Each rank is an integer between 1 and n O(n 2 ) Priority list is a vector of n elements for each person, can be sorted using bucket sort in O(n 2 ) time
14
Stable marriage algorithm Propose-and-reject algorithm Time complexity : –Each iteration each woman receiving a proposal either (1) receives her first proposal (2) rejects some proposal (n-1) –Each woman rejects any man’s proposal at most once, so total rejection times is (n-1) for each woman O(n 2 ) –Total time is O(n 2 ) Man-optimal matching
15
Nonbipartite Cardinality Matching Problem Alternating Paths P=i 1 -i 2 - … i k M –We refer to a path P=i 1 -i 2 - … i k in the graph as an alternating path with respect to a matching M if every consecutive pair of arcs in the path contains one matched and one unmatched arc ex : 1-2-4-3-5
16
Nonbipartite Cardinality Matching Problem Augmenting Paths P –We refer to an odd alternating path P with respect to matching M as an augmenting path if the first and last nodes in the path are unmatched ex : 1-2-4-3-5-6 –Interchanging the matched and unmatched arcs on augmenting paths can add one more cardinality
17
Symmetric Difference S 1 S 2 S 1 ⊕ S 2 S 1 ⊕ S 2 = (S 1 ∪ S 2 )-(S 1 ∩S 2 ) Let S 1 and S 2 be two sets; the symmetric difference of these sets, denoted S 1 ⊕ S 2, is the set S 1 ⊕ S 2 = (S 1 ∪ S 2 )-(S 1 ∩S 2 ) S 1 S 2 S 1 ⊕ S 2 for example, S 1 = {4,5,7,8} and S 2 = {2,4,8,9}, then S 1 ⊕ S 2 ={2,5,7,9}
18
Property 12.6 MP MM ⊕ P |M| + 1 M ⊕ P P If M is a matching and P is an augmenting path with respect to M, then M ⊕ P is a matching of cardinality |M| + 1. Moreover, in the matching M ⊕ P, all the matched nodes in M remain matched and two additional nodes, namely the first and last nodes of P, are matched
19
Property 12.7 MM* G* = (N, M ⊕ M*) If M and M* are two matchings, their symmetric difference defines the subgraph G* = (N, M ⊕ M*) with the property that every component is one of the six types shown in Figure 12.7
21
Augmenting Path Theorem pM pp If a node p is unmatched in a matching M, and this matching contains no augmenting path that starts at node p, then node p is unmatched in some maximum matching.
22
Bipartite Matching Algorithm M Start with a feasible matching M (which might be a null matching) and then repeat the following step for every unmatched node pPM M ⊕ Pp Try to identify an augmenting path starting at node p. If we find such a path P, replace M with M ⊕ P; otherwise, delete node p and all the arcs incident to it from the graph
23
Bipartite Matching Algorithm Search algorithm
24
Bipartite Matching Algorithm
26
Time complexity : n –The search algorithm execute at most n times i O(|A(i)|)O(m) –For each node i, the search procedure performs one of the following two operations at most once (1) examine-even (2) examine-odd, the former operation require O(|A(i)|) time, about O(m) O(nm) –Total time O(nm)
27
Unique label property M p A graph is said to possess a unique label property with respect to a given matching M and a root node p if the search procedure assigns a unique label to every labeled node irrespective of the order in which it examines labeled nodes
28
Bipartite network satisfy it; nonbipartite network doesn’t satisfy it
29
Flower and Blossoms M p A flower, defined with respect to a matching M and a root node p, is a subgraph with two components : even pw p = w –Stem. A stem is an even length alternating path that starts at the root node p and terminates at some node w. We permit the possibility that p = w, in which case we say that the stem is empty odd w w –Blossom. A blossom is an odd length alternating cycle that starts and terminates at the terminal node w of a stem and has no other node in common with the stem. We refer to node w as the base of the blossom
30
Flower and Blossoms
31
Property 12.9 2l+1l l ≧ 0 a) A stem spans 2l+1 nodes and contains l matched arcs for some integer l ≧ 0 2k+1k k ≧ 1. b) A blossom spans 2k+1 nodes and contains k matched arcs for some integer k ≧ 1. The matched arcs match all nodes of the blossom except its base c) The base of blossom is an even node
32
Property 12.10 i Every node i in the blossom (except its base) is reachable from the root (or from the base of the blossom) through two distinct alternating paths. One has even length and the other has odd length
33
Contracting a Blossom A(b) = A(i 1 ) ∪ A(i 2 ) ∪ … ∪ A(j k ) 1. Introduce a new node b (pseudonode) and define its adjacency list A(b) = A(i 1 ) ∪ A(i 2 ) ∪ … ∪ A(j k ) 2. Update the adjacency list of every node A(j)=A(j) ∪ {b} by executing A(j)=A(j) ∪ {b} 3. To be able to recover, set contracted node to “inactive” mode
36
Nonbipartite matching algorithm
37
Nonbipartite matching algorithm-- Find a augmenting path
38
Complexity of nonbipartite matching algorithm Lemma 12.13 n/2 –During an execution of the search procedure, the algorithm performs at most n/2 contractions n/2 3n/2 Since each contraction adds at most one element to any adjacency list (the pseudonode), and since the algorithm performs at most n/2 contractions, no adjacency list will ever contain more than 3n/2 i |A c (i)| ≦ 3n/2, O(n 2 ) Each search procedure performs one of the following operation at most once: (1)it discovers that node i is inactive (2)examine-odd(3)examine-even, (3) require |A c (i)| ≦ 3n/2, so running time is O(n 2 ) O(n 3 ) Total time complexity O(n 3 )
39
Chapter 13 MINIMUM SPANNING TREES
40
Outline Introduction Optimality Condition Kruskal’s Algorithm Prim’s Algorithm Sollin’s Algorithm
41
Introduction
42
Optimality Condition Cut Optimality Conditions T* –A Spanning tree T* is a minimum spanning tree if and only if it satisfies the following cut optimality condition: For every tree arc, c ij ≦ c kl (k, l) (i, j)T* c ij ≦ c kl for every arc (k, l) contained in the cut formed by deleting arc (i, j) from T*
43
Optimality Condition Path Optimality Conditions (k, l) Gc ij ≦ c kl (i, j) T*kl –A spanning tree T* is a minimum spanning tree if and only if it satisfies the following path optimality conditions: For every nontree arc (k, l) of G, c ij ≦ c kl for every arc (i, j) contained in the path in T* connecting nodes k and l
44
Kruskal’s Algorithm O(mn ) Time Complexity O(mn )
45
Prim’s Algorithm O(m log n) Time Complexity O(m log n)
46
Sollin’s Algorithm O(m log n) Time Complexity O(m log n)
47
Summary of minimum spanning tree algorithm
48
Matroids and the Greedy Algorithm I Independent : a subset I of objects do not form a cycle in the network (E, ζ) ζ Subset System (E, ζ) : a finite set of objects E and nonempty collection ζ of subsets of these objects I p I p+1 pp+1 I p ∪ {e} Matroid : a subset system satisfies the growth property that if I p and I p+1 are independent sets containing p and p+1 elements, we always can find an element, satisfying the property that I p ∪ {e} is an independent set
49
Matroids and the Greedy Algorithm Maximal independent set : an independent set I satisfying the property that we cannot add any other element e to I and produce another independent set Greedy algorithm :
50
Thank You!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.