503_lecture5_S11

503_lecture5_S11 - UMass Lowell Computer Science 91.503...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Spring, 2011 i Lecture 5 Tuesday, 2/22/11 y, Graph Algorithms: Part 2 1 Graph Algorithms G h Al i h Discussion of literature paper related to all-pairs shortest l d all- i ll h p paths... 2 Goal & Approach of Paper Goal: Efficient routing for mobile hosts All hosts have same wireless transmission range. Approach: Represent network by undirected, unweighted graph G = (V, E). (V 2 nodes connected if both hosts are within transmission range Find small, connected, dominating set of gateway nodes In dditi I addition, this set must include all intermediate nodes on every shortest path thi t t i l d ll i t di t d h t t th between 2 nodes in dominating set. AllAll-pairs shortest paths Maintain routing table for gateway nodes. nodes Use heuristic, due to suspected intractability of minimum dominating set problem. 1 2 6 3 4 5 7 8 9 3 source: "On Calculating Connected Dominating Set for Efficient Routing in Ad-Hoc Wireless Networks" Ad- Dominating Set 1 2 6 3 4 5 7 8 9 4 source: Garey & Johnson Marking Heuristic Initialize each node's marker to F (false) ( ) Each vertex v exchanges its open neighbor set N(v) with each of its neighbors N (v) = {u | {u, v} E} Each vertex changes its marker to T (true) if it can determine that it has 2 (directly) unconnected neighbors. Resulting V ' induces reduced graph G ' = G [V ' ]. THEOREM 1 (reworded): If G is (not completely) connected, then V ' is a ( d d) completely) connected dominating set of G. THEOREM 2 (reworded): G ' is connected. THEOREM 3 (reworded): Sh Shortest path b h between any 2 nodes of G ' does d f d not include any non-gateway node as an intermediate node. non1 2 6 3 4 5 7 8 9 5 source: "On Calculating Connected Dominating Set for Efficient Routing in Ad-Hoc Wireless Networks" Ad- Enhanced Marking Heuristic RULES 1 & 2 try to reduce number of gateway nodes t t d b f t d assuming ordering on vertex id's in V ' define closed neighbor set of v in V ': N [v] = N (v) {v} RULE 1: Consider 2 vertices v and u i G ' . If N [v] N [u ] i G and id(v) < 1 C id i d in in d id( d id( id(u), change marker of v to F if node v is marked. RULE 2: Given 2 marked neighbors u and w of marked vertex v in G ', if N (v) N (u ) N ( w) in G and id (v) = min{id (v), id (u ), id ( w)} then change marker of v to F. Paper also discusses dynamic network with hosts turning on and off. Experimental simulation uses random graphs. RULE 1 U v id=1 u id=2 v u u v w RULE 2 6 source: "On Calculating Connected Dominating Set for Efficient Routing in Ad-Hoc Wireless Networks" Ad- Network Flow k l Chapter 26 We won't cover Sections 26.4, 26.5 7 Basic Network Flow Concepts 8 Network Flow edge weights source 2 3 1 3 1 1 Goal: compute second set of edge weights <= capacities* such that flow rate is maximized maximized. 2 3 weighted network sink flow in = flow out (except at source, sink) ( t t i k) source: Sedgewick, Graph Algorithms flow fl direction 9 *upper bound on flow rate = units/time Network Flow Applications Di ib i Problems Distribution P bl move objects from place to place within network examples: merchandise communications traffic flow 10 source: Sedgewick, Graph Algorithms Network Flow Applications (continued) M t hi Problems Matching P bl network represents ways to connect vertices goal: choose connections to l h ti t cover vertex set only touch each vertex once examples: job placement minimum-distance point matching (2 point sets) minimum Matchine airplanes to routes 11 source: Sedgewick, Graph Algorithms Network Flow Applications (continued) Cut Problems remove edges to cut network into >= 2 pieces, disconnecting source from sink examples: network reliability cutting supply lines Def.: Def.: A cut (S, T) of a flow network G = (V, E) T) E) is a partition of V into S and T = V - S such that s S and t T. 12 source: Sedgewick, Graph Algorithms Flow Definitions Flow network G = (V, E) (V directed graph g p each edge (u,v) in E has capacity (u,v) c(u,v) >= 0 every vertex is on some path from source s to sink t G is connected |E| >= |V| - 1 |V 13 capacity 2 3 1 3 1 1 2 3 source: 91.503 textbook Cormen et al. Flow Properties Flow in G is f: V x V -> R satisfying: Capacity Constraint: u , v V 0 f (u , v) c(u , v) Flow Conservation: u V - {s, t} vV f (v, u ) = vV f (u , v) fl entering a vertex other than source or sink must = fl l i flow i h h i k flow leaving the vertex Value of a flow f is total net flow out of source: source: | f |= vV f ( s, v) - vV f (v, s ) 14 | | denotes flow value source: 91.503 textbook Cormen et al. Flow Networks Source: Prof. Pecelli Antiparallel edges: elimination. p g 15 Augmenting Paths 16 Controlling Network Flow open switches along augmenting path < 0,1,3,5> 2 leave s open switches along augmenting th 0,2,4,5> path < 0 2 4 5 3 leave s 2 flow into t reduce by 1 increase by 1 3 flow into t change switch at 1 to redirect flow to fill 1-4; 1add flow on < 0,2,3,5 > (maxflow results) augmenting path <0,2,3,1,4,5,> is harder to find here! 17 * full source: Sedgewick, Graph Algorithms Augmenting Flow on a Path Dissecting augmenting path: <0,2,3,1,4,5> 2 2 1 2 1 2 increase flow in <0,2> increase flow in <2,3> increase flow in <3,1> = decrease flow in <1,3> 1 1 increase flow on <1,4>,<4,5> Final result: flow increases from 3 to 4 18 source: Sedgewick, Graph Algorithms Augmenting Path Sequences Try #1 Strategy: Keep trying until no augmenting path can b f i h be found. d Same final max flow in each case although strategy is greedy! To show strategy always produces max flow, 3 key ideas: ) g gp 1) augmenting paths 2) residual networks 3) cuts Try #2 Try #3 y 19 source: Sedgewick, Graph Algorithms Augmenting Paths in Residual Networks 20 Residual Networks sources: 91.503 textbook Cormen et al. and Prof. Pecelli al. min capacity on this p y augmenting path residual network Gf and an augmenting path Note: Antiparallel edges can appear in residual graph. augmented flow in Gf. Is there another augmenting path here? residual capacity flow network G and flow f The backward capacity of an edge is exactly the current flow (in the correct direction) on the edge. augmented flow in G (no edges with 0 residual capacity are shown) c(u , v) - f (u , v) if (u , v) E c f (u , v) = residual capacity = f (v, u ) if (v, u ) E 0 otherwise E f = {(u,v) V V : c f (u , v) > 0} 21 Edges of residual graph Residual Networks sources: 91.503 textbook Cormen et al. and Prof. Pecelli al. Augmentations. If f is a flow in G and f' is a flow in the Augmentations. g f ' corresponding residual network Gf, we define f f , the augmentation of the flow f by f', to be a function from f', V x V to R, defined by f (u,v ) + f ' (u,v ) - f ' (v,u) if (u,v ) E, (26.4) f f ')(u,v ) = , ( 0 otherwise. See the previous slide for an example. example. Given a flow f on (u, v), we increase it by f'(u, v) and f'( decrease it by f'(v, u) : pushing flow on the reverse edge is f'( 3/2/2011 22 the same as reducing flow in the original network. Residual Networks sources: 91.503 textbook Cormen et al. and Prof. Pecelli al. Lemma 26 1. Let G = (E V) be a flow network with source 26.1. 26.1 E, V) s, sink t, capacity c and a flow f. Let Gf be the residual network of G induced by f, let f' be a flow in Gf. Then f f ,' the augmentation of fl h i f flow f b f' , d fi d by by defined b f (u,v ) + f ' (u,v ) - f ' (v,u) if (u,v ) E, (26.4) ( f f ')(u,v ) = otherwise. otherwise 0 is a flow in G with value (flow sum) f f ' = f + f ' . Proof. Proof. To show that f f ' is a flow, we must show that capacity constraints and flow conservation are obeyed at each vertex in V {s, t}; we also show that the correct value is obtained. obtained 3/2/2011 23 Residual Networks sources: 91.503 textbook Cormen et al. and Prof. Pecelli al. Capacity constraint: if (u,v ) E , then cf(v, u) = f(u, v). This constraint: implies that f'(v, u) cf(v, u) = f(u, v), since the augmenting flow on f'( (v, u) cannot be larger than the residual capacity on (v, u). Using the definitions: ( f f ')(u, v ) = f (u, v ) + f ' (u, v ) - f ' (v, u ) b (26 4) by (26.4) f (u , v ) + f ' (u , v ) - f (u , v ) by f ' (v, u ) f (u , v ) = f ' (u , v ) 0. by (26.4) flows are non - neg. capacity constraint definition of c f 24 Flow is non-negative. It never exceeds capacity: non- ( f f ')(u, v ) = f (u, v ) + f ' (u, v ) - f ' (v, u ) f (u , v ) + f ' (u , v ) f (u , v ) + c f (u , v ) = c(u , v ). = f (u , v ) + c(u , v ) - f (u , v ) 3/2/2011 . Residual Networks sources: 91.503 textbook Cormen et al. and Prof. Pecelli al. Flow conservation: f and f' obey flow conservation, since conservation: they are flows. u V - {s,t}, )( ( f f ')(u,v ) = ( f (u,v ) + f ' (u,v ) - f ' (v,u)) v V v V = = = = f (u,v ) + f ' (u,v ) - f ' (v,u) f (v,u) + f ' (v,u) - f ' (u,v ) v,u v,u u,v ( f (v u) + f ' (v u) - f ' (u v )) v V v V v V v V v V v V v V ( f f ')(v,u). 25 Where the third line f ll Wh th thi d li follows from the second by flow f th d b fl conservation of the two flows. 3/2/2011 v V Residual Networks sources: 91.503 textbook Cormen et al. and Prof. Pecelli al. Value: Value: This is somewhat more complex the algebra is a little messier and takes about a page of the textbook. We start with the observation that f is defined on G and not on Gf. Recall we disallow antiparallel edges in G. For each v in V we can have either (s, v) in E or (v, s) in E, but not both. If we define V1 = {v: (s, v) in E}, V2 = {v: (v, s) in E}, {v (s {v (v we must have V1 V2 E and V1 V2 = . Use the definition of value of a flow on a graph (G): (G f f ' = ( f f ')(s,v ) - ( f f ')(v,s) v V = ( f f ')(s,v ) - ( f f ')(v,s), v V2 v V As we split V and observe that v V1 ( f f ')(w, x ) = 0 )( if (w, x ) E E. 26 3/2/2011 Residual Networks sources: 91.503 textbook Cormen et al. and Prof. Pecelli al. We now use the definition of f f ', reorder, regroup and finish the algebra: g p g f f' = ( f (s,v ) + f ' (s,v ) - f ' (v,s)))- ( f (v,s) + f ' (v,s) - f ' (v,s))) v V1 v V2 K see textbook (p. 719) for missing steps K = f + f' 3/2/2011 27 Residual Networks sources: 91.503 textbook Cormen et al. and Prof. Pecelli al. Augmenting Paths. Let G = (V, E) be a flow network with a flow f. An augmenting Paths. E) path p is a simple path from s to t in the residual network Gf. We define the residual capacity of p: cf(p) = min{cf(u, v): (u, v) on p}. min{c v): (u, v) Lemma 26 2. L t G = (V E) b a flow network, f a fl in G, p an augmenting path in L 26.2. 26.2 Let V, E) be fl t k flow i ti th i Gf. Define f p :V V R c f ( p) f p (u,v ) = 0 if (u,v ) is on p otherwise. ( (26.8) ) Then fp is a flow in Gf, with value |fp| = cf(p) > 0. 0. Proof. Ex. 26.2-7. Proof. Ex 26.2-7 26 2 Corollary 26.3. Let G = (V, E) be a flow network, f a flow in G, p an 26.3. E) augmenting path in Gf. L t fp b defined as above. ti th i Let be d fi d b f fp = f + fp > f . Then f f p is a flow in G with value 3/2/2011 Proof: Proof: Immediate from previous results in Lemmas 26.1 and 26.2. 28 Cuts 29 s-t Cut Disconnects source from sink 30 source: Sedgewick, Graph Algorithms Cuts sources: 91.503 textbook Cormen et al. and Prof. Pecelli al. Def.: Def.: A cut (S, T) of a flow network G = (V, E) f S T) f fl k E) is a partition of V into S and T = V - S s.t. s.t. s S and t T. If f is a flow, f(S, T) is the net flow across the cut , , T) (26.9) (S, T): f (S,T ) = f (u,v ) - f (v,u) T) The capacity of the cut is c(S,T ) = c(u,v ). A minimum cut of a network is a cut whose capacity is minimum over all cuts of the network. 3/2/2011 31 Example on next slide... uS v T uS v T uS v T Cuts "Negative" flow edges are excluded from cut capacity, but are included in calculating net flow across cut: f (S T) (S,T) c(S,T)=29 c(S,T)=26 f (S,T)=19 c(S,T)=24 Minimum cut is cut (S,T) whose capacity is minimum over all s-t cuts of network. 32 source: 91.503 textbook Cormen et al. Cuts sources: 91.503 textbook Cormen et al. and Prof. Pecelli al. Lemma 26.4. Let f be a flow in a network G = (V, E), with source s and sink t. Let (S, T) be 26.4. E) T) a cut of G. Then the net flow across (S, T) is f(S, T) = |f |. T) T) |f Proof. Proof. Flow conservation for nodes u in V {s, t} can be written as f (u,v ) - f (v,u) = 0. v V v V Recall f = f (s,v ) - f (v,s). v V v V Summing the zeros over S {s} to |f|, and other algebra: f = f (s,v ) - f (v,s) + f (u,v ) - f (v,u) v V v V uS-{s} v V v V = = f (s,v ) - f (v,s) + f (u,v ) - f (v,u) v V v V uS-{s} v V uS-{s} v V f (u,v ) - f (v,u) v V uS v V uS v S uS v T uS - now use V = S T and S T = = f (u,v ) + f (u,v ) - f (v,u) - f (v,u) v S uS v T uS = f (u,v ) - f (v,u) + f (u,v ) - f (v,u) v S uS v T uS v T uS v S uS = f (u,v ) - f (v,u) = f (S,T ). 3/2/2011 uS v T uS v T by definition (26.9) 33 Cuts sources: 91.503 textbook Cormen et al. and Prof. Pecelli al. Corollary 26.5. The value of any flow f in a flow network G 26.5. is bounded above by the capacity of any cut in G. f c( S , T ) Proof. Let P f L (S, T) b any cut of G, f any fl be f flow. f = f (S,T ) = uS uS uS v T f (u,v ) - uS v T f (v,u) by definition (26.9) v T v T f (u,v ) c (u,v ) = c (S,T ). A useful immediate observation is that the maximum flow must be bounded by the capacity of a minimum cut. This cut. would lead to the conjecture, possibly backed up by an ld l d t th j t ibl b k d b algorithm and a proof, that the two quantities are the same...34 3/2/2011 Max-Flow Min-Cut Theorem 35 Max-Flow Min-Cut Theorem source: 91.503 textbook Cormen et al. If f is a flow in a flow network G=(V, E) =(V with source s and sink t, then, equivalently: 1. 1 f is a maximum flow in G 2. The residual network Gf contains no augmenting paths 3. | f | = c(S,T) for some cut (S,T) of G (S 1 3 proof strategy 36 2 source: 91.503 textbook Cormen et al. Max-Flow Min-Cut Theorem Proof Layout Eq 26.4 ( f f (u , v ) + f ' (u , v ) - f ' (v, u ) if (u , v ) E , f ')(u , v ) = otherwise. otherwise 0 Lemma 26.1 Net fl N t flow across (S T) i f(S, T) = |f |. S, T) is S T) |f f f ' = f + f '. c f ( p) f p (u,v ) = , 0 Eq 26.8 if (u,v ) is on p otherwise. Lemma 26.4 (2) -> (3) Lemma 26.2 fp is a flow in Gf, with value |fp| = cf(p) > 0. a ue 0. f c( S , T ) (3) -> (1) Corollary 26.5 Corollary 26.3 f f p = f + f p > f ( ) ( ) (1) -> (2) MaxMax-Flow Min-Cut MinTheorem 26.6 37 Ford-Fulkerson Max-Flow Method 38 General Approach source: 91.503 textbook Cormen et al. 39 Flow Networks sources: 91.503 textbook Cormen et al. and Prof. Pecelli al. We are now ready to state a more detailed (|E variant of Ford-Fulkerson.(|E|) time Fordtermination? Each iteration of while loop can be executed in O(|E|) time O(|E = time to find path in residual network using BFS or DFS 3/2/2011 40 Flow Networks sources: 91.503 textbook Cormen et al. and Prof. Pecelli al. Analysis. Analysis. The first two lines are easy: ( E ). But things can go bad from here. Start with " particular strategy" for how we choose the S i h "no i l "f h h h augmenting path, but assume that all capacities have integer f y values. Let f* denote the maximum flow found by the algorithm, with |f*| denoting its (integer) value. It is f*| conceivable that each pass of the while loop (lines 4-8) will 4increase the value of the flow by a single unit - but not less. less Since finding an augmenting path (or finding that one does not exists) might require examining all the edges of Gf, the total t t l cost of the loop is O(|E|||f*|) - recall that the number of t f th l i (|E||f*|) |f* | ll th t th b f edges in Gf is never more than double that of G. 3/2/2011 41 Flow Networks source: 91.503 textbook Cormen et al. Problem: 7 3/2/2011 42 Shortest Augmenting Paths Edmonds-Karp BreadthEdmonds Karp Breadth-First Search p path length = 3 g path length = 4 path length = 4 path length = 5 path length = 7 43 source: Sedgewick, Graph Algorithms source: 91.503 textbook Cormen et al. Shortest Augmenting Paths Edmonds-Karp Edmonds Karp Time is in O(|V||E|2): O(|V||E ) (| Each iteration of while loop takes time in O(|E|) O(|E Number of iterations is in O(|V||E|) O(|V||E Shortest-path distance in residual network increases Shortestmonotonically with each flow augmentation Total number of augmentations is in O(|V||E|) O(|V||E Proof Sketch: Edge in residual network is critical on augmenting path if u,v) residual capacity of path is residual capacity of (u,v) Critical edge disappears from residual network Critical edge reappears only if net flow from u to v is decreased; happens only if (v,u) appears later on another augmenting path From time (u,v) becomes critical to time it next becomes critical, distance of u from source increases by >= 2 44 (u,v) becomes critical at most O(|V|) times ...
View Full Document

This note was uploaded on 02/13/2012 for the course CS 91.503 taught by Professor Staff during the Spring '11 term at UMass Lowell.

Ask a homework question - tutors are online