520 likes | 663 Views
Network Flow and Connectivity in Wireless Sensor Networks. Youn-Hee Han yhhan@kut.ac.kr Korea University of Technology and Education Laboratory of Intelligent Networks (LINK) http://link.kut.ac.kr. Edited and Copied From Slides by Kevin Wayne. Max Flow. [Definition] Flow network :
E N D
NetworkFlow and Connectivity in Wireless Sensor Networks Youn-Hee Han yhhan@kut.ac.kr Korea University of Technology and EducationLaboratory of Intelligent Networks (LINK) http://link.kut.ac.kr Edited and Copied FromSlides by Kevin Wayne
Max Flow • [Definition] Flow network: • an edge-capacitated directed graph, with two distinguished vertices called the source and the sink. • Features: • Abstraction for material flowing through the edges. • G = (V, E) = directed graph • Two distinguished nodes: s = source, t = sink. • c(e) = capacity of edge e. 2 5 9 10 15 15 10 4 source sink 5 s 3 6 t 8 10 15 4 6 10 15 capacity 4 7 30
2 5 9 10 15 15 10 4 5 s 3 6 t 8 10 15 4 6 10 15 4 7 30 Max Flow • [Definition] flow: • A flow in a network X is a function f that assigns to each edge e of the network a real number f(e), in such a way that: 0 4 0 0 0 4 0 4 4 0 0 0 0 capacity flow 0 0
2 5 9 10 15 15 10 4 5 s 3 6 t 8 10 15 4 6 10 15 4 7 30 Max Flow • [Definition] flow (or s-t flow): • A flow in a network X is a function f that assigns to each edge e of the network a real number f(e), in such a way that: 0 4 0 0 0 4 0 4 4 0 0 0 0 capacity flow 0 0
2 5 9 10 15 15 10 4 5 s 3 6 t 8 10 15 4 6 10 15 4 7 30 Max Flow • [Definition] Value Q : • The value Q of a flow in a network X is: 0 4 0 0 0 4 0 4 4 0 0 0 0 Value Q = 4 capacity flow 0 0
2 5 9 10 15 15 10 4 5 s 3 6 t 8 10 15 4 6 10 15 4 7 30 Max Flow • [Definition] Value Q : • The value Q of a flow in a network X is: 6 10 6 0 0 4 3 8 8 1 10 0 0 Value Q = 24 capacity flow 11 11
2 5 9 10 15 15 10 4 5 s 3 6 t 8 10 15 4 6 10 15 4 7 30 Max Flow • [Definition] Max Flow Problem: • find the maximum possible value Q of a flow in X and find a flow route of that value. 9 10 9 1 0 0 4 9 8 Value Q = 28 (Max) 4 10 0 0 capacity flow 14 14
Min Cut • [Definition] cut(A,B) (or s-t cut) : • By a cut (A,B), we mean a partition (A, B) of V with s A and t B. • [Definition] capacity of a cut • The capacity of a cut (A, B) is: 2 5 9 10 15 15 10 4 5 s 3 6 t 8 10 A 15 4 6 10 15 cap(A,B) = 9 + 15 + 8 + 30 = 62 4 7 30
Min Cut • [Definition] Min Cut Problem: • find a cut of the minimum capacity in X 2 5 9 10 15 15 10 4 5 s 3 6 t 8 10 cap(A,B) = 10 + 8 + 10 = 28 15 4 6 10 A 15 4 7 30
Min Cut • [Definition] Min Cut Problem: • find a cut of the minimum capacity in X cut(U,V) is a minimum cut : its capacity is the sum of the capacities crossing the cut = 1+2=3=cap(U,V). : the edge (i,j) is not included in cap(U,V) because it is going in the wrong direction.
Flows and Cuts • [Lemma 1] Let f be “any” flow, and let cut(A, B) be “any” cut. Then, the net flow sent across the cut is equal to the value Q. 6 2 5 9 10 6 0 10 15 15 0 10 4 4 3 8 8 5 s 3 6 t 8 10 A 1 10 15 0 0 4 6 10 15 11 11 Net flow across the cut= 10+3+11= 24 (= Value Q) 4 7 30
Flows and Cuts • [Lemma 1] Let f be “any” flow, and let cut(A, B) be “any” cut. Then, the net flow sent across the cut is equal to the value Q. 6 2 5 9 10 6 0 10 15 15 0 10 4 4 3 8 8 5 s 3 6 t 8 10 A 1 10 15 0 0 4 6 10 15 11 11 Net flow across the cut= 6 + 0 + 8 - 1 + 11 = 24 (= Value Q) 4 7 30
Flows and Cuts • [Lemma 1] Let f be “any” flow, and let cut(A, B) be “any” cut. Then, the net flow sent across the cut is equal to the value Q. 2 5 9 10 6 0 10 15 15 0 10 4 4 3 8 8 5 s 3 6 t 8 10 A 1 10 15 0 0 4 6 10 15 11 11 Net flow across the cut = 10 - 4 + 8 - 0 + 10= 24 (= Value Q) 4 7 30
Flows and Cuts • [Lemma 1] Let f be “any” flow, and let cut(A, B) be “any” cut. Then, the net flow sent across the cut is equal to the value Q. • Proof] The net flow out of s is Q. The net flow out of any other vertex v in A is 0. So, we obtain:
Flows and Cuts • [Lemma 2] Let f be “any” flow, and let cut(A, B) be “any” cut. Then the value Q of the flow is at most the capacity cap(A,B) of the cut. 6 2 5 9 10 6 0 10 15 15 0 10 4 4 3 8 8 5 s 3 6 t 8 10 A 1 10 15 0 0 4 6 10 15 11 11 4 7 30 Value Q = 24 cap(A,B) = 30
Flows and Cuts • [Lemma 2] Let f be “any” flow, and let cut(A, B) be “any” cut. Then the value Q of the flow is at most the capacity cap(A,B) of the cut. 6 2 5 9 10 6 0 10 15 15 0 10 4 4 3 8 8 5 s 3 6 t 8 10 A 1 10 15 0 0 6 4 10 15 11 11 Value Q = 24 cap(A,B) = 64(=9+15+8+30) 4 7 30
Flows and Cuts • [Lemma 2] Let f be “any” flow, and let cut(A, B) be “any” cut. Then the value Q of the flow is at most the capacity cap(A,B) of the cut. 2 5 9 10 6 0 10 15 15 0 10 4 4 3 8 8 5 s 3 6 t 8 10 A 1 10 15 0 0 4 6 10 15 11 11 Value Q = 24 cap(A,B) = 28(=10+8+10) 4 7 30
Flows and Cuts • [Lemma 2] Let f be “any” flow, and let cut(A, B) be “any” cut. Then the value Q of the flow is at most the capacity cap(A,B) of the cut. • Proof]
Max Flow = Min Cut • [Theorem] The maximum flow valueQ in a network X is equal to the minimum capacity of any cut in X. In other words, Let f be “any” flow, and let (A, B) be “any” cut. If Q= cap(A, B), then the flow f is a max flow and cut(A, B) is a min cut. Value Q = 28Cut capacity = 28 9 2 5 9 10 9 1 10 15 15 0 10 0 4 4 9 8 5 s 3 6 t 8 10 4 10 15 0 A 0 4 6 10 15 14 14 4 7 30
Max Flow = Min Cut • [Theorem] The maximum flow valueQ in a network X is equal to the minimum capacity of any cut in X. In other words, Let f be “any” flow, and let (A, B) be “any” cut. If Q= cap(A, B), then the flow f is a max flow and cut(A, B) is a min cut. Value Q = 3Cut capacity = 3 1 1 1 1 1 2 2 2 2 2 0 0 0 0 0
Max Flow Algorithm: Greedy • Greedy algorithm. • Start with f(e) = 0 for all edge e E. • Find an s-t path P where each edge has f(e) < c(e). • Augment flow along path P. • Repeat until you get stuck. 1 0 0 20 10 30 0 t s 10 20 Flow value = 0 0 0 2
Max Flow Algorithm: Greedy • Greedy algorithm. • Start with f(e) = 0 for all edge e E. • Find an s-t path P where each edge has f(e) < c(e). • Augment flow along path P. • Repeat until you get stuck. 1 20 0 0 X 20 10 20 30 0 t X s 10 20 Flow value = 20 20 0 0 X 2
Max Flow Algorithm: Greedy • Greedy algorithm. • Start with f(e) = 0 for all edge e E. • Find an s-t path P where each edge has f(e) < c(e). • Augment flow along path P. • Repeat until you get stuck. locally optimality ≠ global optimality 1 1 20 0 20 10 20 10 20 10 30 20 30 10 t t s s 10 20 10 20 0 20 10 20 2 2 greedy = 20 opt = 30
Max Flow Algorithm: Ford-Fulkerson capacity • Original edge: e = (u, v) E. • Flow f(e), capacity c(e). • Residual edge. • "Undo" flow sent. • e = (u, v) and eR = (v, u). • Residual capacity: • Residual graph: Gf = (V, Ef ). • Residual edges with positive residual capacity. • Ef = {e} {eR : c(e) > 0}. u v 17 6 flow residual capacity u v 11 6 residual capacity
Max Flow Algorithm: Ford-Fulkerson • Original edge: e = (u, v) E. • Flow f(e), capacity c(e). • Residual edge. • "Undo" flow sent. • e = (u, v) and eR = (v, u) • Residual capacity: • Residual graph: Gf = (V, Ef ). • Residual edges with positive residual capacity. • Ef = {e} {eR : c(e) > 0}. 1 2 5 1 1 1 1 1 1 s 4 t 1 1 1 3
Max Flow Algorithm: Ford-Fulkerson • Original edge: e = (u, v) E. • Flow f(e), capacity c(e). • Residual edge. • "Undo" flow sent. • e = (u, v) and eR = (v, u) • Residual capacity: • Residual graph: Gf = (V, Ef ). • Residual edges with positive residual capacity. • Ef = {e} {eR : c(e) > 0}. 1 2 5 1 1 1 1 1 1 s 4 t 1 1 1 3 Find any augmenting path in G(x) A augmenting path is a path from s to t along with we can push some additional flow
Max Flow Algorithm: Ford-Fulkerson • Original edge: e = (u, v) E. • Flow f(e), capacity c(e). • Residual edge. • "Undo" flow sent. • e = (u, v) and eR = (v, u) • Residual capacity: • Residual graph: Gf = (V, Ef ). • Residual edges with positive residual capacity. • Ef = {e} {eR : c(e) > 0}. 1 2 5 1 1 1 1 0 1 1 s 4 t 1 0 1 1 0 1 1 1 3 Determine the bottleneck of the path.: the bottleneck is the flow of the path Update residual capacities.
Max Flow Algorithm: Ford-Fulkerson • Original edge: e = (u, v) E. • Flow f(e), capacity c(e). • Residual edge. • "Undo" flow sent. • e = (u, v) and eR = (v, u) • Residual capacity: • Residual graph: Gf = (V, Ef ). • Residual edges with positive residual capacity. • Ef = {e} {eR : c(e) > 0}. 1 2 5 1 1 1 1 1 s 4 t 1 1 1 1 3 Find any s-t path in G(x)
Max Flow Algorithm: Ford-Fulkerson • Original edge: e = (u, v) E. • Flow f(e), capacity c(e). • Residual edge. • "Undo" flow sent. • e = (u, v) and eR = (v, u) • Residual capacity: • Residual graph: Gf = (V, Ef ). • Residual edges with positive residual capacity. • Ef = {e} {eR : c(e) > 0}. 1 2 5 1 1 1 1 1 0 s 4 t 1 1 2 0 1 1 1 0 1 1 3 Determine the bottleneck of the path.: the bottleneck is the flow of the path Update residual capacities.
Max Flow Algorithm: Ford-Fulkerson • Original edge: e = (u, v) E. • Flow f(e), capacity c(e). • Residual edge. • "Undo" flow sent. • e = (u, v) and eR = (v, u) • Residual capacity: • Residual graph: Gf = (V, Ef ). • Residual edges with positive residual capacity. • Ef = {e} {eR : c(e) > 0}. 1 2 5 1 1 1 1 1 2 1 1 s 4 t 1 1 1 1 1 1 1 1 1 1 3 Find any s-t path in G(x)
Max Flow Algorithm: Ford-Fulkerson • Original edge: e = (u, v) E. • Flow f(e), capacity c(e). • Residual edge. • "Undo" flow sent. • e = (u, v) and eR = (v, u) • Residual capacity: • Residual graph: Gf = (V, Ef ). • Residual edges with positive residual capacity. • Ef = {e} {eR : c(e) > 0}. 1 0 2 5 1 1 0 1 1 0 1 1 1 s 4 t 1 1 1 1 1 1 1 1 1 1 3 Determine the bottleneck of the path.: the bottleneck is the flow of the path Update residual capacities.
Max Flow Algorithm: Ford-Fulkerson • Original edge: e = (u, v) E. • Flow f(e), capacity c(e). • Residual edge. • "Undo" flow sent. • e = (u, v) and eR = (v, u) • Residual capacity: • Residual graph: Gf = (V, Ef ). • Residual edges with positive residual capacity. • Ef = {e} {eR : c(e) > 0}. 2 5 1 1 1 1 1 s 4 t 1 1 1 1 1 1 1 1 1 1 3 There is no s-t path in the residual network. This flow is optimal
1 2 5 1 1 1 1 s 4 t 1 1 3 Max Flow Algorithm: Ford-Fulkerson Here is the optimal flow
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 value Q = 0 34
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 value Q = 0 2 4 4 residual capacity Gf: 6 8 10 10 2 10 s 3 5 t 10 9 35
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 value Q = 8 2 4 4 Gf: 8 6 8 10 2 2 10 s 3 5 t 2 9 8 36
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 value Q = 10 2 4 4 Gf: 6 8 10 10 2 10 s 3 5 t 10 7 2 37
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 value Q = 16 2 4 4 Gf: 6 6 8 4 10 2 4 s 3 5 t 10 1 6 8 38
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 value Q = 18 2 2 4 2 Gf: 8 6 8 2 10 2 2 s 3 5 t 10 1 8 8 39
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 value Q = 19 3 2 4 1 Gf: 9 1 6 7 1 10 2 1 s 3 5 t 10 9 9 40
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 value Q = 19 3 2 4 1 Gf: 9 1 6 7 1 10 2 1 s 3 5 t 10 9 9 • The partition A becomes the set of vertices reachable from s in residual graph. 41
Max Flow Algorithm: Ford-Fulkerson Ford-Fulkerson(G(V,E), s, t, c) { Gf(V,Ef) G(V,E) while (there exists augmenting path P) { b bottleneck(P) foreach e P { if (e E) c(e) c(e) - b else c(eR) c(eR) + b } update G } return the current flow value Q } //forward edge update Gf //reverse edge
Max-Flow Min-Cut Theorem • Augmenting path theorem. Flow f is a max flow iff there are no augmenting paths. • Max-flow min-cut theorem. [Ford-Fulkerson 1956] The value of the max flow is equal to the value of the min cut. • Proof strategy. We prove both simultaneously by showing the TFAE: (i) There exists a cut (A, B) such that Q = cap(A, B). (ii) Flow f is a max flow. (iii) There is no augmenting path relative to f. • (i) (ii) This was the corollary to weak duality lemma. • (ii) (iii) We show contrapositive. • Let f be a flow. If there exists an augmenting path, then we can improve f by sending flow along path.
Proof of Max-Flow Min-Cut Theorem • (iii) (i) • Let f be a flow with no augmenting paths. • Let A be set of vertices reachable from s in residual graph. • By definition of A, s A. • By definition of f, t A.
K-Edge-Connectivity • [Definition]k-edge-connectivity • The network will remain connected after removing any arbitrary k-1 edges from network. • k-edge-connected: any pair of nodes are connected by k disjoint paths • disjoint paths: 45
Edge Disjoint Paths • Disjoint path problem. • Given a digraph G = (V, E) and two nodes s and t, find the max number of edge-disjoint s-t paths. • [Def] Two paths are edge-disjoint if they have no edge in common. • Ex: communication networks. 2 5 s 3 6 t 4 7
Edge Disjoint Paths • Disjoint path problem. • Given a digraph G = (V, E) and two nodes s and t, find the max number of edge-disjoint s-t paths. • [Def] Two paths are edge-disjoint if they have no edge in common. • Ex: communication networks. 2 5 s 3 6 t 4 7
s t Edge Disjoint Paths • Max flow formulation: assign unit capacity to every edge. • [Theorem] Max number edge-disjoint s-t paths equals max flow value. Proof • Suppose there are k edge-disjoint paths P1, . . . , Pk. • Set f(e) = 1 if e participates in some pathPi ; else set f(e) = 0. • Since paths are edge-disjoint, f is a flow of value Q=k. ▪ 1 1 1 1 1 1 1 1 1 1 1 1 1 1
s t Edge Disjoint Paths • Max flow formulation: assign unit capacity to every edge. • [Theorem] Max number edge-disjoint s-t paths equals max flow value. Proof • Suppose max flow value Q is k. • Then, there exists 0-1 flow f of value k. • Consider edge (s, u) with f(s, u) = 1. • by conservation, there exists an edge (u, v) with f(u, v) = 1 • continue until reach t, always choosing a new edge • Produces k (not necessarily simple) edge-disjoint paths. 1 1 1 1 1 1 1 1 1 1 1 1 1 1 can eliminate cycles to get simple paths if desired
Network Connectivity • [Network connectivity] Given a digraph G = (V, E) and two nodes s and t, find min number of edges whose removal disconnects t from s. • Def. A set of edges F E disconnects t from s if all s-t paths uses at least one edge in F. 2 5 2 5 s 3 6 t s 3 6 t 4 7 4 7 F