Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 5 Tuesday, 3/2/10 Graph Algorithms: Part 2

Similar presentations


Presentation on theme: "Lecture 5 Tuesday, 3/2/10 Graph Algorithms: Part 2"— Presentation transcript:

1 Lecture 5 Tuesday, 3/2/10 Graph Algorithms: Part 2
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2010 Lecture 5 Tuesday, 3/2/10 Graph Algorithms: Part 2

2 Graph Algorithms Discussion of literature paper related to all-pairs shortest paths…

3 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). 2 nodes connected if both hosts are within transmission range Find small, connected, dominating set of gateway nodes In addition, this set must include all intermediate nodes on every shortest path between 2 nodes in dominating set. All-pairs shortest paths Maintain routing table for gateway nodes. Use heuristic, due to suspected intractability of minimum dominating set problem. 1 2 3 4 5 6 7 8 9 source: “On Calculating Connected Dominating Set for Efficient Routing in Ad-Hoc Wireless Networks”

4 Dominating Set 1 2 3 4 5 6 7 8 9 source: Garey & Johnson

5 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 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 dominating set of G. THEOREM 2 (reworded): G ’ is connected. THEOREM 3 (reworded): Shortest path between any 2 nodes of G ’ does not include any non-gateway node as an intermediate node. 1 2 3 4 5 6 7 8 9 source: “On Calculating Connected Dominating Set for Efficient Routing in Ad-Hoc Wireless Networks”

6 Enhanced Marking Heuristic
RULES 1 & 2 try to reduce number of gateway nodes assuming ordering on vertex id’s in V ’ define closed neighbor set of v in V ’: RULE 1: Consider 2 vertices v and u in G ’ . If in G and id(v) < 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 in G and 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 RULE 2 v u v u u v w id=1 id=2 source: “On Calculating Connected Dominating Set for Efficient Routing in Ad-Hoc Wireless Networks”

7 Network Flow Chapter 26 We won’t cover Sections 26.4, 26.5

8 Basic Network Flow Concepts

9 (except at source, sink)
Network Flow edge weights Goal: compute second set of edge weights <= capacities such that flow is maximized. source 2 3 1 sink weighted network flow in = flow out (except at source, sink) flow direction source: Sedgewick, Graph Algorithms

10 Network Flow Applications
Distribution Problems move objects from place to place within network examples: merchandise communications traffic flow source: Sedgewick, Graph Algorithms

11 Network Flow Applications (continued)
Matching Problems network represents ways to connect vertices goal: choose connections to cover vertex set only touch each vertex once examples: job placement minimum-distance point matching (2 point sets) Matchine airplanes to routes source: Sedgewick, Graph Algorithms

12 Network Flow Applications (continued)
Cut Problems remove edges to cut network into >= 2 pieces, disconnecting source from sink examples: network reliability cutting supply lines source: Sedgewick, Graph Algorithms

13 Flow Definitions Flow network G = (V, E) directed graph
each edge (u,v) in E has capacity c(u,v) >= 0 every vertex is on some path from source s to sink t G is connected |E| >= |V| - 1 capacity 2 3 1 source: textbook Cormen et al.

14 Flow Properties Flow in G is f: VxV -> R satisfying:
Capacity Constraint: Flow Conservation: flow entering a vertex other than source or sink must = flow leaving the vertex Value of a flow f is total net flow out of source: | | denotes flow value source: textbook Cormen et al.

15 Flow Networks Antiparallel edges: elimination.
sources: textbook Cormen et al.

16 Augmenting Paths

17 Controlling Network Flow
open switches along augmenting path < 0,1,3,5> open switches along augmenting path < 0,2,4,5> 3 leave s 2 leave s 2 flow into t 3 flow into t reduce by 1 change switch at 1 to redirect flow to fill 1-4; add flow on < 0,2,3,5 > (maxflow results) increase by 1 augmenting path is harder to find here! * full source: Sedgewick, Graph Algorithms

18 Augmenting Flow on a Path
Dissecting augmenting path: <0,2,3,1,4,5> 2 2 1 1 2 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 source: Sedgewick, Graph Algorithms

19 Augmenting Path Sequences
Try #1 Strategy: Keep trying until no augmenting path can be found. Same final max flow in each case although strategy is greedy! To show strategy always produces max flow, key ideas: augmenting paths residual networks cuts Try #3 Try #2 source: Sedgewick, Graph Algorithms

20 Augmenting Paths in Residual Networks

21 (no edges with 0 residual capacity are shown)
Residual Networks min capacity on this augmenting path sources: textbook Cormen et al. and Prof. Pecelli residual capacity residual network Gf and an augmenting path flow network G and flow f The backward capacity of an edge is exactly the current flow (in the correct direction) on the edge. Note: Antiparallel edges can appear in residual graph. augmented flow in Gf. Is there another augmenting path here? augmented flow in G (no edges with 0 residual capacity are shown)

22 Residual Networks sources: textbook Cormen et al. and Prof. Pecelli Augmentations. If f is a flow in G and f’ is a flow in the corresponding residual network Gf, we define , the augmentation of the flow f by f’, to be a function from V x V to R, defined by See the previous slide for an example. Given a flow f on (u, v), we increase it by f’(u, v) and decrease it by f’(v, u) : pushing flow on the reverse edge is the same as reducing flow in the original network. (26.4) 1/17/2019

23 Residual Networks sources: textbook Cormen et al. and Prof. Pecelli Lemma Let G = (E, V) be a flow network with source 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 , the augmentation of flow f by f’ , defined by is a flow in G with value (flow sum) Proof. To show that 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. (26.4) 1/17/2019

24 Residual Networks sources: textbook Cormen et al. and Prof. Pecelli Capacity constraint: if , then cf(v, u) = f(u, v). This implies that f’(v, u) ≤ cf(v, u) = f(u, v), since the augmenting flow on (v, u) cannot be larger than the residual capacity on (v, u). Using the definitions: Flow is non-negative. It never exceeds capacity: 1/17/2019

25 Residual Networks sources: textbook Cormen et al. and Prof. Pecelli Flow conservation: f and f’ obey flow conservation, since they are flows. Where the third line follows from the second by flow conservation of the two flows. 1/17/2019

26 Residual Networks sources: textbook Cormen et al. and Prof. Pecelli 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}, we must have Use the definition of value of a flow on a graph (G): As we split V and observe that 1/17/2019

27 Residual Networks sources: textbook Cormen et al. and Prof. Pecelli We now use the definition of , reorder, regroup and finish the algebra: 1/17/2019

28 Residual Networks sources: textbook Cormen et al. and Prof. Pecelli Augmenting Paths. Let G = (V, E) be a flow network with a flow f. An augmenting 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}. Lemma Let G = (V, E) be a flow network, f a flow in G, p an augmenting path in Gf. Define Then fp is a flow in Gf, with value |fp| = cf(p) > 0. Proof. Ex Corollary Let G = (V, E) be a flow network, f a flow in G, p an augmenting path in Gf. Let fp be defined as above. Then is a flow in G with value Proof: Immediate from previous results in Lemmas 26.1 and 26.2. (26.8) 1/17/2019

29 Cuts

30 Cut Disconnects source from sink source: Sedgewick, Graph Algorithms

31 Cuts sources: textbook Cormen et al. and Prof. Pecelli Def.: A cut (S, T) of a flow network G = (V, E) is a partition of V into S and T = V - S s.t. If f is a flow, f(S, T) is the net flow across the cut (S, T): The capacity of the cut is A minimum cut of a network is a cut whose capacity is minimum over all cuts of the network. (26.9) 1/17/2019 Example on next slide…

32 What is it for this network?
Cuts “Negative” flow edges are excluded from cut capacity, but are included in calculating net flow across cut: f (S,T) c(S,T)=29 c(S,T)=24 c(S,T)=26 f (S,T)=19 Minimum cut is cut (S,T) whose capacity is minimum over all s-t cuts of network. What is it for this network? source: textbook Cormen et al.

33 Cuts Example on previous slide…
sources: textbook Cormen et al. and Prof. Pecelli Lemma Let f be a flow in a network G = (V, E), with source s and sink t. Let (S, T) be a cut of G. Then the net flow across (S, T) is f(S, T) = |f |. Proof. Flow conservation for nodes u in V – {s, t} can be written as Recall Summing the zeros over S – {s} to |f|, and other algebra: by definition (26.9) 1/17/2019 Example on previous slide…

34 Cuts sources: textbook Cormen et al. and Prof. Pecelli Corollary The value of any flow f in a flow network G is bounded above by the capacity of any cut in G. Proof. Let (S, T) be any cut of G, f any flow. A useful immediate observation is that the maximum flow must be bounded by the capacity of a minimum cut. This would lead to the conjecture, possibly backed up by an algorithm and a proof, that the two quantities are the same… by definition (26.9) 1/17/2019

35 Max-Flow Min-Cut Theorem

36 Max-Flow Min-Cut Theorem
source: textbook Cormen et al. If f is a flow in a flow network G=(V, E) with source s and sink t, then, equivalently: f is a maximum flow in G The residual network Gf contains no augmenting paths | f | = c(S,T) for some cut (S,T) of G max flow = min cut 1 2 3 proof strategy source: textbook Cormen et al.

37 Max-Flow Min-Cut Theorem Proof Layout
Eq 26.4 Lemma 26.1 Eq 26.8 Net flow across (S, T) is f(S, T) = |f |. Lemma 26.4 (2) -> (3) Lemma 26.2 fp is a flow in Gf, with value |fp| = cf(p) > 0. (3) -> (1) Corollary 26.5 Corollary 26.3 (1) -> (2) Max-Flow Min-Cut Theorem 26.6

38 Ford-Fulkerson Max-Flow Method

39 Ford-Fulkerson: General Approach
source: textbook Cormen et al.

40 Ford-Fulkerson: More Detail
sources: textbook Cormen et al. and Prof. Pecelli We are now ready to state a more detailed variant of Ford-Fulkerson. Q(|E|) time termination? Each iteration of while loop can be executed in O(|E|) time = time to find path in residual network using BFS or DFS 1/17/2019

41 Ford-Fulkerson: Analysis
sources: textbook Cormen et al. and Prof. Pecelli Analysis. The first two lines are easy: But things can go bad from here. Start with “no particular strategy” for how we choose the augmenting path, but assume that all capacities have integer values. Let f* denote the maximum flow found by the algorithm, with |f*| denoting its (integer) value. It is conceivable that each pass of the while loop (lines 4-8) will increase the value of the flow by a single unit - but not less. Since finding an augmenting path (or finding that one does not exists) might require examining all the edges of Gf, the total cost of the loop is O(|E|•|f*|) - recall that the number of edges in Gf is never more than double that of G. 1/17/2019

42 Ford-Fulkerson: Analysis
source: textbook Cormen et al. Problem: 7 1/17/2019

43 Shortest Augmenting Paths Edmonds-Karp
Use Ford-Fulkerson, but compute augmenting paths by BFS of Gf. source: Sedgewick, Graph Algorithms

44 Shortest Augmenting Paths Edmonds-Karp
source: textbook Cormen et al. Time is in O(|V||E|2): Each iteration of while loop takes time in O(|E|) Number of iterations is in O(|V||E|) Shortest-path distance in residual network increases monotonically with each flow augmentation Total number of augmentations is in O(|V||E|) Proof Sketch: Edge in residual network is critical on augmenting path if 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 (u,v) becomes critical at most O(|V|) times


Download ppt "Lecture 5 Tuesday, 3/2/10 Graph Algorithms: Part 2"

Similar presentations


Ads by Google