460 likes | 472 Views
Learn about maximum flow networks, Ford-Fulkerson algorithm, residual networks, cuts, and the max-flow min-cut theorem.
E N D
Maximum Flows Corman book
Max Flow Network Max flow network: G = (V, E, s, t, u) . • (V, E) = directed graph, no parallel arcs. • Two distinguished nodes: s = source, t = sink. • c(e) = capacity of arc e. 2 5 9 10 15 15 10 4 5 s 3 6 t 8 10 15 4 6 10 Capacity 15 4 7 30
Flows • An s-t flow is a function f: E R+ that satisfies: • For each e E: 0 f(e) c(e) (capacity) • For each v V – {s, t}: (conservation) 0 2 5 9 4 0 0 10 15 15 0 10 4 4 0 4 4 5 s 3 6 t 8 10 0 0 15 0 4 0 6 10 Capacity 15 0 Flow 4 7 30 0
Flows • An s-t flow is a function f: E R+ that satisfies: • For each e E: 0 f(e) c(e) (capacity) • For each v V – {s, t}: (conservation) 0 2 5 9 4 0 0 10 15 15 0 10 4 4 0 4 4 5 s 3 6 t 8 10 0 0 15 0 4 0 6 10 Capacity 15 Value = 4 0 Flow 4 7 30 0
Flows An s-t flow is a function f: E R+ that satisfies: • For each e E: 0 f(e) c(e) (capacity) • For each v V – {s, t}: (conservation) MAX FLOW: find s-t flow that maximizes net flow out of the source.
Max Flow Network • We can reduce the problem of determining a maximum flow in a network with multiple sources and multiple sinks to an ordinary maximum-flow problem.
Max Flow Network • We can reduce the problem of determining a maximum flow in a network with multiple sources and multiple sinks to an ordinary maximum-flow problem. • Add a supersource s and a supersink • Connect each sink si to s by an edge with capacity ∞. • Similarly connect each sink tj to t by an edge with capacity ∞.
Ford-Fulkerson Method • Iteratively increases the value of the flow. • Start with f(e) = 0 for all e, giving an initial flow of value 0. • The flow is increased in G by finding an “augmenting path” in an associated “residual network” Gf. • Increase flow in G can then be pushed along the edges of the augmenting path.
Residual Networks • Flow network G=(V,E) with source node s and sink node t. • Let f be a flow in G. • Define the residual capacity cf(u,v) by • cf(u,v) = c(u,v) –f(u,v) • cf(v,u) = f(u,v) if f(u,v) > 0 • We assume that if (u,v) is an element of E, (v,u) is not an element of E.
Ford-Fulkerson Algorithm 0 flow 2 4 4 capacity G: 0 0 0 6 0 8 10 10 2 0 0 0 0 10 s 3 5 t 10 9 Flow value = 0
8 X 8 X 8 X Ford-Fulkerson Algorithm 0 flow 2 4 4 capacity G: 0 0 0 6 0 8 10 10 2 0 0 0 0 10 s 3 5 t 10 9 Flow value = 0 2 4 4 residual capacity Gf: 6 8 10 10 2 10 s 3 5 t 10 9
8 X 8 X 8 X Ford-Fulkerson Algorithm 0 flow 2 4 4 capacity G: 0 0 0 6 0 8 10 10 2 0 0 0 0 10 s 3 5 t 10 9 Flow value = 0 2 4 4 residual capacity Gf: 6 8 10 10 2 10 s 3 5 t 10 9 Apply BFS from s in Gf to find an augmenting path to t, if exists.
10 X X 2 10 X 2 X Ford-Fulkerson Algorithm 0 2 4 4 G: 0 8 8 6 0 8 10 10 2 0 0 8 0 10 s 3 5 t 10 9 Flow value = 8 2 4 4 Gf: 8 6 8 10 2 2 10 s 3 5 t 2 9 8
6 X X 6 6 X 8 X Ford-Fulkerson Algorithm 0 2 4 4 G: 0 10 8 6 0 8 10 10 2 2 0 10 2 10 s 3 5 t 10 9 Flow value = 10 2 4 4 Gf: 6 8 10 10 2 10 s 3 5 t 10 7 2
2 X 8 X X 0 8 X Ford-Fulkerson Algorithm 0 2 4 4 G: 6 10 8 6 6 8 10 10 2 2 6 10 8 10 s 3 5 t 10 9 Flow value = 16 2 4 4 Gf: 6 6 8 4 10 2 4 s 3 5 t 10 1 6 8
3 X 9 X 7 X 9 X 9 X Ford-Fulkerson Algorithm 2 2 4 4 G: 8 10 8 6 6 8 10 10 2 0 8 10 8 10 s 3 5 t 10 9 Flow value = 18 2 2 4 2 Gf: 8 6 8 2 10 2 2 s 3 5 t 10 1 8 8
Ford-Fulkerson Algorithm 3 2 4 4 G: 9 10 7 6 6 8 10 10 2 0 9 10 9 10 s 3 5 t 10 9 Flow value = 19 3 2 4 1 Gf: 9 1 6 7 1 10 2 1 s 3 5 t 10 9 9
Ford-Fulkerson Algorithm 3 2 4 4 G: 9 10 7 6 6 8 10 10 2 0 9 10 9 10 s 3 5 t 10 9 Cut capacity = 19 Flow value = 19 3 2 4 1 Gf: 9 1 6 7 1 10 2 1 s 3 5 t 10 9 9
Residual Networks • Flow network G=(V,E) with source node s and sink node t. • Let f be a flow in G. • Define the residual capacity cf(u,v) by • cf(u,v) = c(u,v) –f(u,v) • cf(v,u) = f(u,v) if f(u,v) > 0 • We assume that if (u,v) is an element of E, (v,u) is not an element of E.
Cuts in the Flow Network • How do we know that when the algorithm terminates, we have found a maximum flow? • Max-flow min-cut theorem is very famous.
Cuts in the Flow Network • A cut (S,T) of flow network G=(V,E) is a partition of V into S and T=V-S such that s ε S and t ε T. • net flow f(S,T)is defined as follows:
Cuts in the Flow Network • A cut (S,T) of flow network G=(V,E) is a partition of V into S and T=V-S such that s ε S and t ε T. • net flow f(S,T)is defined as follows: f(S,T) = 19
Cuts in the Flow Network • A cut (S,T) of flow network G=(V,E) is a partition of V into S and T=V-S such that s ε S and t ε T. • net flow f(S,T)is defined as follows: • The capacity of the cut (S,T) is
Cuts in the Flow Network • net flow f(S,T)is defined as follows: • The capacity of the cut (S,T) is f(S,T) = 19 c(S,T) = 27
Cuts in the Flow Network • net flow f(S,T)is defined as follows: • The capacity of the cut (S,T) is A minimum cut of a network is a cut whose capacity is minimum over all the cuts f(S,T) = 19 c(S,T) = 27
History Year Discoverer Method Big-Oh 1951 Dantzig Simplex mn2U 1955 Ford, Fulkerson Augmenting path mnU 1970 Edmonds-Karp Shortest path m2n 1970 Dinitz Shortest path mn2 1972 Edmonds-Karp, Dinitz Capacity scaling m2 log U 1973 Dinitz-Gabow Capacity scaling mnlog U 1974 Karzanov Preflow-push n3 1983 Sleator-Tarjan Dynamic trees mn log n 1986 Goldberg-Tarjan FIFO preflow-push mnlog (n2 / m) . . . . . . . . . . . . 1997 Goldberg-Rao Length function m3/2 log (n2 / m) log Umn2/3 log (n2 / m) log U
Applications of Flow Network • Find the min-cut of G =(V,E) separating two given nodes u and v. • Treat u as the source node and v as sink node. • Set the capacity of each edge to be 1. • Solve the max-flow problem in G. • Size of min-cut separting u and v is |f| where f is the maximum flow.
Edge Connectivity of an Undirected Graphs • The edge connectivity of an undirected graph is the minimum number k of edges that must be removed to disconnect the graph.
Edge Connectivity of an Undirected Graphs • The edge connectivity of an undirected graph is the minimum number k of edges that must be removed to disconnect the graph.
Maximum Bipartite Matching • A matching of an undirected graph G = (V,E) is a subset of edges M of E such that for all vertices v of V, at most one edge of M is incident on v. • A maximum matching is a matching of maximum cardinality. • An undirected graph G = (V, E) is a bipartite graph if V can be partitioned into L and R such that for every (u,v) of E, u ε L and v ε R.
Maximum Bipartite Matching • Corresponding Flow Network. • We let the source s and sink t be new vertices not in V,and we let V’ = V U {s, t}. • E’ = {(s,u) : u ε L} U {(v, t) : v ε R} U {(u,v) : (u,v) εE}. • Assign unit capacity to each edge. • The maximum flow in G’ = (V’, E’) realizes the maximum matching.
maximum edge-disjoint paths between s and t • Corresponding Flow Network. • Source s and sink t are elements of V. • G=(V,E) is our graph • Assign unit capacity to each edge. • The maximum flow in G = (V, E) realizes the maximum edge-disjoint paths.
Escape Problem (Cormanet.al page 760) • Given n x n grid. • m starting points (x1, y1), …, (xm,ym) are given. • Determine whether there are m vertex disjoint paths from the starting points to any m different points on the boundary.