Lecture 9, Mar 9 - PowerPoint PPT Presentation

1 / 48
About This Presentation
Title:

Lecture 9, Mar 9

Description:

A bipartite graph is a graph G=(V,E) in which V can be divided into two parts L ... Reduce an instance of the maximum bipartite matching problem on graph G to an ... – PowerPoint PPT presentation

Number of Views:95
Avg rating:3.0/5.0
Slides: 49
Provided by: jeffed
Category:
Tags: bipartite | lecture | mar

less

Transcript and Presenter's Notes

Title: Lecture 9, Mar 9


1
Lecture 9, Mar 9
2
CSC373Algorithm Design and AnalysisAnnouncements
  • Assignment 3 Q2 assume A is unsorted.
  • Test 2 in two weeks.

3
Network Flows
4
The Problem
  • Use a graph to model material that flows through
    conduits.
  • Each edge represents one conduit, and has a
    capacity, which is an upper bound on the flow
    rate units/time.
  • Can think of edges as pipes of different sizes.
    But flows dont have to be of liquids.
  • Want to compute max rate that we can ship
    material from a designated source to a designated
    sink.

5
The Ford-Fulkerson Method
  • Try to improve the flow, until we reach the
    maximum.
  • The residual capacity of the network with a flow
    f is given by

Always nonnegative (why?)
6
Example of residual capacities
Network
7
The residual network
  • The edges of the residual network are the edges
    on which the residual capacity is positive.

8
Augmenting Paths
  • An augmenting path p is a simple path from s to t
    on the residual network.
  • We can put more flow from s to t through p.
  • We call the maximum capacity by which we can
    increase the flow on p the residual capacity of p.

9
Ford-Fulkerson Method
10
Example
11
Cuts of Flow Networks
  • A cut in a network is a partition of V into S and
    TV-S so that s is in S and t is in T.

12
Lemma (7.6)
  • For any cut (S,T), the net flow across (S,T) is
    f(S,T)f.

13
Corollary
  • The value of any flow f in a flow network G is
    bounded from above by the capacity of any cut of
    G.

14
Theorem (7.9) (Max-flow min-cut theorem)
  • If f is a flow in a flow network G(V,E), with
    source s and sink t, then the following
    conditions are equivalent
  • f is a maximum flow in G.
  • The residual network Gf contains no augmented
    paths.
  • f c(S,T) for some cut (S,T) (a min-cut).

15
The Basic Ford-Fulkerson Algorithm
16
Example
4
17
Example
18
Example
Residual Network
Resulting Flow
11
19
Example
20
Example
19
21
Example
22
Example
23
23
Example
24
Analysis
25
Analysis
  • If capacities are all integer, then each
    augmenting path raises f by 1.
  • If max flow is f, then need f iterations,
    so the time is O(Ef).
  • Note that this running time is not polynomial in
    input size. It depends on f, which is not a
    function of V or E.
  • If capacities are rational, can scale them to
    integers.
  • If irrational, FORD-FULKERSON might never
    terminate!

26
The basic Ford-Fulkerson Algorithm
  • With time O ( E f), the algorithm is not
    polynomial.
  • This problem is real Ford-Fulkerson may perform
    very badly if we are unlucky

f2,000,000
27
Run Ford-Fulkerson on this example
Augmenting Path
Residual Network
28
Run Ford-Fulkerson on this example
Augmenting Path
Residual Network
29
Run Ford-Fulkerson on this example
  • Repeat 999,999 more times

30
The Edmonds-Karp Algorithm
  • A small fix to the Ford-Fulkerson algorithm makes
    it work in polynomial time.
  • Specify how to compute the path in line 4.

31
The Edmonds-Karp Algorithm
  • Compute the path in line 4 using breadth-first
    search on residual network.
  • The augmenting path p is the shortest path from s
    to t in the residual network (treating all edge
    weights as 1).
  • Runs in time O(V E2).

32
The Edmonds-Karp Algorithm - example
  • Edmonds-Karps algorithm runs only 2 iterations
    on this graph.

33
Further Improvements
  • Push-relabel algorithm (CLRS, 26.4) O(V2 E).
  • The relabel-to-front algorithm (CLRS, 26.5)
    O(V3).
  • The scaling Max-Flow algorithm (section 7.3)
    O(E2 log C), where C is the maximum integer
    capacity.

34
Maximum Bipartite Matching
  • A bipartite graph is a graph G(V,E) in which V
    can be divided into two parts L and R such that
    every edge in E is between a vertex in L and a
    vertex in R.
  • e.g. vertices in L represent skilled workers and
    vertices in R represent jobs. An edge connects
    workers to jobs they can perform.

35
  • A matching in a graph is a subset M of E, such
    that for all vertices v in V, at most one edge of
    M is incident on v.

36
  • A maximum matching is a matching of maximum
    cardinality.

maximal not maximum
maximum
37
A Maximum Matching
  • No matching of cardinality 4, because only one of
    v and u can be matched.
  • In the workers-jobs example a max-matching
    provides work for as many people as possible.

v
u
38
Solving the Maximum Bipartite Matching Problem
  • Greedy algorithm?
  • Reduce an instance of the maximum bipartite
    matching problem on graph G to an instance of the
    max-flow problem on a corresponding flow network
    G.
  • Solve using Ford-Fulkerson method.

39
Corresponding Flow Network
  • To form the corresponding flow network G' of the
    bipartite graph G
  • Add a source vertex s and edges from s to L.
  • Direct the edges in E from L to R.
  • Add a target vertex t and edges from R to t.
  • Assign a capacity of 1 to all edges.
  • Claim max-flow in G corresponds to a
    max-bipartite-matching on G.

40
Example
M 3 ?? max flow 3
41
Lemma
42
Why cant we just say max f max M?
  • Problem we havent shown that f(u,v) is
    necessarily integer-valued for all (u,v) when f
    is a max flow.
  • It follows from the lemma that
  • max M max integral flow,
  • but we also need
  • max integral flow max f

43
Integrality Theorem
  • If the capacity function c takes on only integral
    values, then
  • The maximum flow f produced by the Ford-Fulkerson
    method has the property that f is
    integer-valued.
  • For all vertices u and v the value f(u,v) of the
    flow is an integer.
  • So M max integral flow max f
  • Another reason?

44
Conclusion
  • Network flow algorithms allow us to find the
    maximum bipartite matching fairly easily.
  • Similar techniques are applicable in other
    combinatorial design problems.

45
Example
  • In a department there are n courses and m
    instructors.
  • Every instructor has a list of courses he or she
    can teach.
  • Every instructor can teach at most 3 courses
    during a year.
  • The goal find an allocation of courses to the
    instructors subject to these constraints.

46
Two solutions using network flows
  • Solution 1 convert the problem into a bipartite
    matching problem.
  • Solution 2 convert the problem into a flow
    problem directly.

47
A more complicated problem
  • There are m student groups on campus.
  • We would like to form a committee with a
    president, 3 vice-pres, and 10 members at large.
  • The committee is formed by representatives of the
    groups.
  • Can add conditions
  • The first group can be represented by at most 2
    members, any other group can be represented by at
    most one.
  • The representative of the third group cannot be
    the president.
  • Reduce to network flows!

48
Project selection sec. 7.10
Write a Comment
User Comments (0)
About PowerShow.com