Approximate overview
Other good things
A Sample Graph
S->A: 4
A->B: 3
B->T: 8
S->C: 5
C->D: 7
D->T: 3
D->B: 2
C->A: 6
Our revised algorithm
While augmenting paths remain in G
Find the augmenting path with CRITERION
Find the lowest weight edge on that path
Let its weight be w.
Decrement every edge in P by w.
Increment every corresponding edge in the flow graph by w
Possible criteria
All of these are wrong!
Recall that without the criterion, Taking SCABT then SCDT eliminates any other augmenting paths, but only gives us a flow of 5.
Add some pointless edges to make us take the SCABT route.
I<H -> J (to A)
|/
G A -> B --> F
/ ^ ^ \
S | | T
\ | | /
H > C -> D --> E
|
|
v
F
Put a bunch of edges between S and A (all with the same weight as SA).
Put a bunch of edges between C and D (all with the same weight as CD).
A -> B
*^ ^\
S | | T
\| |/
C ** D
A -> B
/^ ^\
S | | T
\| |/
C -> D
A -> B
/^ ^\
S | | T
\| |/
C -> D
A -> B
/^ ^\
S | | T
\| |/
C -> D
Key idea:
While augmenting paths remain in G
Find an augmenting path
Find the lowest weight edge on that path
Let its weight be w.
Decrement every edge in P by w.
Increment the corresponding back edges by w.
(Note: The back edge of a back edge is the original edge.)
Increment every corresponding edge in the flow graph by w
Note: Augmenting paths do not loop.
See whiteboard.
Long and involved.
#loops x cost of finding augmenting path x cost of updating along path
A
/^\
S | T
\|/
B
``` SBAT SABT SBAT SABT ``
Whoops!
Moral: Choose good augmenting paths!
You have two subgraphs A and B.
Edges run only from nodes in A to nodes in B.
Find the largest possible set of edges given the restriction that no element in A has more than one outgoing edge, and no element in B has more than one incoming edge.
Applications: Pet adoption. Job assignments. Gift giving.
How does max flow help with bipartite matching?
We extend the graph with two extra nodes, S and T
There is an edge from S to everything in set A.
There is an edge from everything in set B to T.
The weight of all edges is 1.
Find the max flow.
That’s the largest set of edges between A and B.
Important issue: Max Flow ends up being a great way to solve a wide variety of other problems.
We have n workers, each of whom can complete a certain integer workload (w1 … wn).
We have t tasks, each of which requires a corresponding integer workload (v1 … vt).
Each worker has a set of tasks that they are able to do. (Not all workers are able to do all tasks.)
Find the set of assignments that will maximize the amount of work that gets done.