Title: Network%20Flows
1Network Flows
- Chun-Ta, Yu
- Graduate Institute
- Information Management Dept.
- National Taiwan University
2Chapter 12
- ASSIGHMENTS AND MATCHINGS
3Outline
- Introduction
- Bipartite Cardinality Matching Problem
- Bipartite Weighted Matching Problem
- Stable Marriage Problem
- Nonbipartite Cardinality Matching Problem
4Introduction
- Bipartite matching problem
- The cardinality problem
- The weighted problem
- Stable marriage problem
- Nonbipartite matching problem
5Bipartite 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
6Bipartite Cardinality Matching Problem
7Bipartite Weighted Matching Problem
- Assignment problem
- Given a weighted bipartite network
-
8Bipartite Weighted Matching Problem
- The assignment problem can be viewed as
adaptation of algorithm for the minimum cost flow
problem - Four algorithm to solve
- Successive Shortest Path Algorithm
- Hungarian Algorithm
- Relaxation Algorithm
- Cost Scaling Algorithm
9Successive Shortest Path Algorithm
- Discuss in section 9.7
- Augment 1 unit flow in every iteration
- Let S( n ,m ,C) denote the time needed to solve a
shortest path problem with nonnegative arc
lengths and n1N1 - The algorithm would terminate within n1
iterations and would require O(n1S( n ,m ,C))
10Hungarian Algorithm
- Discuss in section 9.7, primal-dual algorithm
- 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 - The algorithm would terminate within n1
iterations and would require O(n1S( n ,m ,C))
11Relaxation Algorithm
- Closely related to the successive shortest path
algorithm - Relax the constraint
- thus allowing any node in N2 to be assigned
to more than one node in N1 - Overall running time O(n1S( n ,m ,C))
12Stable 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(n2) time
13Stable Marriage Problem
- The input to the stable marriage problem consists
of two n 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(n2)
time
14Stable 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 mans proposal at most
once, so total rejection times is (n-1) for each
woman - Total time is O(n2)
- Man-optimal matching
15Nonbipartite Cardinality Matching Problem
- Alternating Paths
- We refer to a path Pi1-i2-ik 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 - ex1-2-4-3-5
16Nonbipartite Cardinality Matching Problem
- Augmenting Paths
- 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 - ex1-2-4-3-5-6
- Interchanging the matched and unmatched arcs on
augmenting paths can add one more cardinality
17Symmetric Difference
- Let S1 and S2 be two sets the symmetric
difference of these sets, denoted S1?S2, is the
set S1?S2 (S1?S2)-(S1nS2) - for example, S1 4,5,7,8 and S2 2,4,8,9
, then S1?S2 2,5,7,9
18Property 12.6
- 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
19Property 12.7
- 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
20(No Transcript)
21Augmenting Path Theorem
- 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.
22Bipartite Matching Algorithm
- Start with a feasible matching M (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 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
23Bipartite Matching Algorithm
24Bipartite Matching Algorithm
25(No Transcript)
26Bipartite Matching Algorithm
- Time complexity
- The search algorithm execute at most n times
- 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) - Total time O(nm)
27Unique label property
- 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 doesnt satisfy it
29Flower and Blossoms
- A flower, defined with respect to a matching M
and a root node p, is a subgraph with two
components - 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 - 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
30Flower and Blossoms
31Property 12.9
- A stem spans 2l1 nodes and contains l matched
arcs for some integer l?0 - A blossom spans 2k1 nodes and contains k matched
arcs for some integer k?1. The matched arcs match
all nodes of the blossom except its base - The base of blossom is an even node
32Property 12.10
- 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
33Contracting a Blossom
- Introduce a new node b (pseudonode) and define
its adjacency list A(b) A(i1)?A(i2)? ?A(jk) - Update the adjacency list of every node
- by executing A(j)A(j)?b
- To be able to recover, set contracted node to
inactive mode
34(No Transcript)
35(No Transcript)
36Nonbipartite matching algorithm
37Nonbipartite matching algorithm-- Find a
augmenting path
38Complexity of nonbipartite matching algorithm
- Lemma 12.13
- During an execution of the search procedure, the
algorithm performs at most n/2 contractions - 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 - 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-e
ven, (3) require Ac(i)?3n/2, so running time is
O(n2) - Total time complexity O(n3)
39Chapter 13
40Outline
- Introduction
- Optimality Condition
- Kruskals Algorithm
- Prims Algorithm
- Sollins Algorithm
41Introduction
42Optimality Condition
- Cut Optimality Conditions
- A Spanning tree T is a minimum spanning tree if
and only if it satisfies the following cut
optimality condition For every tree arc
, - cij?ckl for every arc (k, l) contained in the
cut formed by deleting arc (i, j) from T
43Optimality 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,
l) of G, cij?ckl for every arc (i, j) contained
in the path in T connecting nodes k and l
44Kruskals Algorithm
45Prims Algorithm
- Time Complexity O(m log n)
46Sollins Algorithm
- Time Complexity O(m log n)
47Summary of minimum spanning tree algorithm
48Matroids and the Greedy Algorithm
- Independenta subset I of objects do not form a
cycle in the network - Subset System (E, ?)a finite set of objects E
and nonempty collection ? of subsets of these
objects - Matroida subset system satisfies the growth
property that if Ip and Ip1 are independent sets
containing p and p1 elements, we always can find
an element , satisfying the
property that Ip?e is an independent set -
49Matroids and the Greedy Algorithm
- Maximal independent setan independent set I
satisfying the property that we cannot add any
other element e to I and produce another
independent set - Greedy algorithm
-
50Thank You!