Presentation is loading. Please wait.

Presentation is loading. Please wait.

UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Fall, 2008 Lecture 5 Tuesday, 10/7/08 Graph Algorithms: Part 2.

Similar presentations


Presentation on theme: "UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Fall, 2008 Lecture 5 Tuesday, 10/7/08 Graph Algorithms: Part 2."— Presentation transcript:

1 UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Fall, 2008 Lecture 5 Tuesday, 10/7/08 Graph Algorithms: Part 2

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

3 Goal & Approach of Paper source: “On Calculating Connected Dominating Set for Efficient Routing in Ad-Hoc Wireless Networks” ä 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 789

4 Dominating Set source: Garey & Johnson 1 2 3 4 5 6 789

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. source: “On Calculating Connected Dominating Set for Efficient Routing in Ad-Hoc Wireless Networks” 1 2 3 4 5 6 789

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. 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. source: “On Calculating Connected Dominating Set for Efficient Routing in Ad-Hoc Wireless Networks” v u v u id=1 id=2

7 Network Flow Chapter 26

8 Basic Network Flow Concepts

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

10 Network Flow Applications Distribution ProblemsDistribution Problems move objects from place to place within networkmove objects from place to place within network examples:examples: merchandisemerchandise communicationscommunications traffic flowtraffic flow source: Sedgewick, Graph Algorithms

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

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

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

14 Flow Properties Flow in G is f: VxV -> R satisfying:Flow in G is f: VxV -> R satisfying: Capacity Constraint:Capacity Constraint: Skew Symmetry:Skew Symmetry: Flow Conservation:Flow Conservation: f (u,v) is net flow from vertex u to vertex vf (u,v) is net flow from vertex u to vertex v positive flow entering vertex v:positive flow entering vertex v: positive flow entering a vertex other than source or sink must = positive flow leaving the vertexpositive flow entering a vertex other than source or sink must = positive flow leaving the vertex Value of a flow f is total net flow out of source:Value of a flow f is total net flow out of source: source: 91.503 textbook Cormen et al.

15 Flow Properties (continued) Lemma 26.1 Lemma 26.1 Let G=(V, E) be a flow network, and let f be a flow in G. Then: Let G=(V, E) be a flow network, and let f be a flow in G. Then: Implicit summation notation: Implicit summation notation: source: 91.503 textbook Cormen et al. Exercise: show

16 source: Sedgewick, Graph Algorithms Flow Properties (continued) Flow Equilibrium A = amount of flow into left set from outside right set B = amount of flow out of left set (and not into right set) C = amount of flow into right set from outside left set D = amount of flow out of right set (and not into left set) y = amount of flow into right set from left set x = amount of flow into left set from right set EQUILIBRIUM requires A + x = B + y C + y = D + x A + C = B + D

17 Controlling Network Flow source: Sedgewick, Graph Algorithms open switches along path open switches along path change switch at 1 to redirect flow to fill 1-4; add flow on (maxflow results) 2 leave s 2 flow into t 3 leave s 3 flow into t increase by 1 reduce by 1

18 Augmenting Paths

19 Augmenting Flow on a Path source: Sedgewick, Graph Algorithms increase flow in 2 2 2 2 decrease flow in increase flow on, 1 1 1 1 2 flow increases from 3 to 4

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

21 Residual Networks

22 source: 91.503 textbook Cormen et al. flow network G and flow f residual network G f and augmenting path augmented flow in G augmented flow in G f min capacity on augmenting path 26.3 26.1 residual capacity flow = amount we can remove (no 0 edges are shown)

23 Cuts

24 s-t Cut source: Sedgewick, Graph Algorithms Disconnects source from sink

25 s-t Cut source: 91.503 textbook Cormen et al. c(S,T)=29 c(S,T)=26 c(S,T)=24 “Negative” flow edges are excluded from cut capacity. Minimum cut is cut (S,T) whose capacity is minimum over all s-t cuts of network.

26 MaxFlow MinCut Theorem If f is a flow in a flow network G=(V, E) with source s and sink t, then, equivalently: If f is a flow in a flow network G=(V, E) with source s and sink t, then, equivalently: 1. f is a maximum flow in G 1. f is a maximum flow in G 2. The residual network G f contains no augmenting paths 2. The residual network G f contains no augmenting paths 3. | f | = c(S,T) for some cut (S,T) of G 3. | f | = c(S,T) for some cut (S,T) of G source: 91.503 textbook Cormen et al.

27 MaxFlow MinCut Theorem Proof Layout Lemma 26.1 Lemma 26.2 Lemma 26.3 Corollary 26.4 Lemma 26.5 Corollary 26.6 Eq 26.6 Eq 26.4 MaxFlow MinCut Theorem 26.7 (3) -> (1) (1) -> (2) (2) -> (3)

28 Ford-Fulkerson MaxFlow Method

29 General Approach source: 91.503 textbook Cormen et al.

30 With Residual Networks source: 91.503 textbook Cormen et al.

31

32 Analysis source: 91.503 textbook Cormen et al. Time depends on method termination?  (|E|) time  ( | max f | ) iterations, assuming integral capacities Each iteration of while loop can be executed in O(|E|) time = time to find path in residual network using BFS or DFS Each iteration of while loop can be executed in O(|E|) time = time to find path in residual network using BFS or DFS Total time =  ( |E| | max f | ) assuming integral capacities Total time =  ( |E| | max f | ) assuming integral capacities

33 Shortest Augmenting Paths Edmonds-Karp source: Sedgewick, Graph Algorithms

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


Download ppt "UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Fall, 2008 Lecture 5 Tuesday, 10/7/08 Graph Algorithms: Part 2."

Similar presentations


Ads by Google