Upload
nicholas-hines
View
18
Download
0
Embed Size (px)
DESCRIPTION
Network Flows. Chun-Ta, Yu Graduate Institute Information Management Dept. National Taiwan University. Chapter 12. ASSIGHMENTS AND MATCHINGS. Outline. Introduction Bipartite Cardinality Matching Problem Bipartite Weighted Matching Problem Stable Marriage Problem - PowerPoint PPT Presentation
Citation preview
Network Flows
Chun-Ta, YuGraduate InstituteInformation Management Dept.National Taiwan University
Chapter 12
ASSIGHMENTS AND MATCHINGS
Outline
Introduction Bipartite Cardinality Matching Problem Bipartite Weighted Matching Problem Stable Marriage Problem Nonbipartite Cardinality Matching Problem
Introduction
Bipartite matching problem1. The cardinality problem
2. The weighted problem
Stable marriage problem Nonbipartite matching problem
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 ( ) O n m
Bipartite Cardinality Matching Problem
Bipartite Weighted Matching Problem Assignment problem Given a weighted bipartite network
1 2 1 2( , ) and arc weights
find a perfect matching of minimum weight
ijG N N A with N N c
( , )
1{ :( , ) }
2{ :( , ) }
1
1
0 ( , )
ij iji j A
ijj i j A
jij j i A
ij
Minimize c x
subject to
x for all i N
x for all i N
x for all i j A
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
Successive Shortest Path Algorithm
Discuss in section 9.7 Augment 1 unit flow in every iteration Let S( S( n ,m ,Cn ,m ,C)) denote the time needed to
solve a shortest path problem with nonnegative arc lengths and nn11=|N=|N11||
The algorithm would terminate within n1 iterations and would require O(O(nn11S( S( n ,m ,Cn ,m ,C))))
Hungarian Algorithm
Discuss in section 9.7, primal-dual algorithm With a single supply node s*s* and a single
demand node t*.t*.At every iteration ,the primal-dual algorithm computes shortest path distance from s*s* to all other nodes
The algorithm would terminate within nn11 iterations and would require O(O(nn11S( S( n ,m ,Cn ,m ,C)) ))
Relaxation Algorithm
Closely related to the successive shortest path algorithm
Relax the constraint
thus allowing any node in NN22 to be assigned to more than one node in NN11
Overall running time O(O(nn11S( S( n ,m ,Cn ,m ,C)) ))
2{ :( , ) }
1 jij j i A
x for all i N
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
For any set of rankings, we can always find a stable matching in O(O(nn22)) time
Stable Marriage Problem
The input to the stable marriage problem consists of two n x nn x n matrices.
Each rank is an integer between 1 and n Priority list is a vector of n elements for each
person, can be sorted using bucket sort in O(O(nn22)) time
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
– Each woman rejects any man’s proposal at most once, so total rejection times is (n-1)(n-1) for each woman
– Total time is O(O(nn22))
Man-optimal matching
Nonbipartite Cardinality Matching Problem Alternating Paths
– We refer to a path P=iP=i11-i-i22--……iikk in the graph as an alternating path with respect to a matching MM if every consecutive pair of arcs in the path contains one matched and one unmatched arc
ex : 1-2-4-3-5
Nonbipartite Cardinality Matching Problem Augmenting Paths
– We refer to an odd alternating path PP 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
Symmetric Difference
Let SS11 and SS22 be two sets; the symmetric difference of these sets, denoted SS11⊕⊕SS22, is the set SS11⊕⊕SS22 = (= (SS11∪∪SS22)-()-(SS11∩∩SS22))
for example, SS11 = {4,5,7,8} and SS22 = {2,4,8,9} , then SS11⊕⊕SS22 ={2,5,7,9}
Property 12.6
If MM is a matching and PP is an augmenting path with respect to MM, then MM⊕⊕PP is a matching of cardinality ||MM| + 1| + 1. Moreover, in the matching MM⊕⊕PP, all the matched nodes in M remain matched and two additional nodes, namely the first and last nodes of PP, are matched
Property 12.7
If MM and M*M* are two matchings, their symmetric difference defines the subgraph G*G* = ( = (NN, , MM⊕⊕M*M*)) with the property that every component is one of the six types shown in Figure 12.7
Augmenting Path Theorem
If a node pp is unmatched in a matching MM, and this matching contains no augmenting path that starts at node pp, then node pp is unmatched in some maximum matching.
Bipartite Matching Algorithm
Start with a feasible matching MM (which might be a null matching) and then repeat the following step for every unmatched node
Try to identify an augmenting path starting at node pp. If we find such a path PP, replace MM with MM⊕⊕PP; otherwise, delete node pp and all the arcs incident to it from the graph
p N
Bipartite Matching Algorithm
Search algorithm
Bipartite Matching Algorithm
Bipartite Matching Algorithm
Time complexity:– The search algorithm execute at most nn times– For each node ii, the search procedure performs
one of the following two operations at most once (1) examine-even (2) examine-odd, the former operation require OO(|A(i)|(|A(i)|)) time, about O(O(mm))
– Total time O(O(nmnm))
Unique label property
A graph is said to possess a unique label property with respect to a given matching MM and a root node pp if the search procedure assigns a unique label to every labeled node irrespective of the order in which it examines labeled nodes
Bipartite network satisfy it; nonbipartite network doesn’t satisfy it
Flower and Blossoms
A flower, defined with respect to a matching MM and a root node pp, is a subgraph with two components:– Stem. A stem is an eveneven length alternating path that starts
at the root node pp and terminates at some node ww. We permit the possibility that p = wp = w, in which case we say that the stem is empty
– Blossom. A blossom is an oddodd length alternating cycle that starts and terminates at the terminal node ww of a stem and has no other node in common with the stem. We refer to node ww as the base of the blossom
Flower and Blossoms
Property 12.9
a) A stem spans 2l+12l+1 nodes and contains ll matched arcs for some integer l 0≧l 0≧
b) A blossom spans 2k+12k+1 nodes and contains kk matched arcs for some integer k 1. ≧k 1. ≧ The matched arcs match all nodes of the blossom except its base
c) The base of blossom is an even node
Property 12.10
Every node ii 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
Contracting a Blossom
1. Introduce a new node b (pseudonode) and define its adjacency list A(A(bb)) = = A(A(ii11) A(∪) A(∪ ii22)∪)∪…… A(∪A(∪ jjkk))
2. Update the adjacency list of every node
by executing A(A(jj))==A(A(jj) {∪) {∪ bb}}
3. To be able to recover, set contracted node to “inactive” mode
( )j A b
Nonbipartite matching algorithm
Nonbipartite matching algorithm-- Find a augmenting path
Complexity of nonbipartite matching algorithm Lemma 12.13
– During an execution of the search procedure, the algorithm performs at most n/2n/2 contractions
Since each contraction adds at most one element to any adjacency list (the pseudonode), and since the algorithm performs at most n/2n/2 contractions, no adjacency list will ever contain more than 3n/23n/2
Each search procedure performs one of the following operation at most once: (1)it discovers that node ii is inactive (2)examine-odd(3)examine-even, (3) require ||AAcc(i)| 3n/2, ≦(i)| 3n/2, ≦ so running time is O(O(nn22))
Total time complexity O(O(nn33))
Chapter 13
MINIMUM SPANNING TREES
Outline
Introduction Optimality Condition Kruskal’s Algorithm Prim’s Algorithm Sollin’s Algorithm
Introduction
Optimality Condition
Cut Optimality Conditions– A Spanning tree T*T* is a minimum spanning tree
if and only if it satisfies the following cut optimality condition: For every tree arc ,
ccijij c≦c≦ klkl for every arc (k, l)(k, l) contained in the cut formed by deleting arc (i, j)(i, j) from T*T*
( , ) *i j T
Optimality Condition
Path Optimality Conditions– 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, (k, l)l) of GG, ccijij c≦c≦ klkl for every arc (i, j)(i, j) contained in the path in T*T* connecting nodes kk and ll
Kruskal’s Algorithm
Time Complexity OO(mn )(mn )
Prim’s Algorithm
Time Complexity OO(m log n) (m log n)
Sollin’s Algorithm
Time Complexity OO(m log n)(m log n)
Summary of minimum spanning tree algorithm
Matroids and the Greedy Algorithm
Independent : a subset II of objects do not form a cycle in the network
Subset System (E, (E, ζ)ζ) : a finite set of objects E and nonempty collection ζζ of subsets of these objects
Matroid : a subset system satisfies the growth property that if IIpp and IIp+1p+1 are independent sets containing pp and p+1 p+1 elements, we always can find an element , satisfying the property that IIpp {e}∪{e}∪ is an independent set
1p pe I I
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:
Thank You!