3/16/98 day 18 ``We should stop.''
A level graph is one which can have all of it's nodes arranged in levels s.t. nodes at level l+1 don't connect to nodes in level l . A level graph is a DAG (directed acyclic graph).
To find the maximal flow (phase) do a depth first search through the DAG. Dinic came up with an O(mn) per phase algorithm. #phases £ n .
Within a phase, saturate a node, then push the flow into the other nodes.
We meed a data structure to operate with:
|
|
|
| ||||
|
|
|
| ||||
|
|
|
| ||||
|
|
|
|
Actually, arrays work just as well
If an edges is saturated associate the cost of saturation with the edge. Since there are m edges which will only saturate at most once, the cost of all saturated edges £ m £ n2 £ n3 .
There are two groups 'boys' and 'girls'. Each boy-girl pair has some 'compatibility rating'. The goal is to match boys to girls, maximizing overall 'compatibility'. The problem can be turned into a maximum flow problem. Make a source connect to all boys, the boys connect to the girls, and the girls connect to the sink. All edges have capacity 1, which means each 'boy' will connect to 1 'girl'.
The algorithm can be specialized to O(mÖn) .
Let M = matches, M* = maximal match.
MÅM* = (M-M*)È(M*-M) = an augmenting path.
All the augmenting paths are disjoint in the maximum matching problem. Do depth first search. When you encounter the sink, pop the stack and remove the searched edges then start over. Each edges is only searched over once so the cost per phase is O(m) . With Ön phases completed, #levels ³ Ön . MÅM* = K vertex disjoint paths from s to t. Length ³ Ön which implies that K £ Ön .
Find the maximum number of edges disjoint paths from a source to a sink. Setup each edge in the graph to have capacity one and solve for the max flow, which will be composed of some number of disjoint paths.
Find the maximum number of vertex disjoint paths. Split all vertices into 2 nodes. The first node has all the incoming edges and connects to the other node. The other node has all the outgoing edges of the original vertex. Now, any flow must go between the 2 nodes and only one flow can go between them which means flows are vertex disjoint.