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

Slides:



Advertisements
Similar presentations
Maximum flow Main goals of the lecture:
Advertisements

1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
Introduction To Algorithms CS 445 Discussion Session 8 Instructor: Dr Alon Efrat TA : Pooja Vaswani 04/04/2005.
MAXIMUM FLOW Max-Flow Min-Cut Theorem (Ford Fukerson’s Algorithm)
The Maximum Network Flow Problem. CSE Network Flows.
Chapter 10: Iterative Improvement The Maximum Flow Problem The Design and Analysis of Algorithms.
1 Maximum Flow w s v u t z 3/33/3 1/91/9 1/11/1 3/33/3 4/74/7 4/64/6 3/53/5 1/11/1 3/53/5 2/22/2 
Advanced Algorithm Design and Analysis (Lecture 8) SW5 fall 2004 Simonas Šaltenis E1-215b
Chapter 23 Minimum Spanning Trees
CS138A Network Flows Peter Schröder. CS138A Flow Networks Definitions a flow network G=(V,E) is a directed graph in which each edge (u,v)
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Lecture 4 Tuesday, 2/19/02 Graph Algorithms: Part 2 Network.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 4 Tuesday, 10/2/01 Graph Algorithms: Part 2 Network.
Yangjun Chen 1 Network Flow What is a network? Flow network and flows Ford-Fulkerson method - Residual networks - Augmenting paths - Cuts of flow networks.
Maximum Flows Lecture 4: Jan 19. Network transmission Given a directed graph G A source node s A sink node t Goal: To send as much information from s.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2008 Lecture 5 Tuesday, 10/7/08 Graph Algorithms: Part 2.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2006 Lecture 5 Wednesday, 10/4/06 Graph Algorithms: Part 2.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2004 Lecture 5 Wednesday, 10/6/04 Graph Algorithms: Part 2.
MAX FLOW CS302, Spring 2013 David Kauchak. Admin.
Maximum Flow Chapter 26.
Yangjun Chen 1 Network Flow What is a network? Flow network and flows Ford-Fulkerson method - Residual networks - Augmenting paths - Cuts of flow networks.
Announcements Network Flow today, depending on how far we get, we will do String Matching on Wednesday Then Review for Final next Monday This week’s lab.
Single Source Shortest-Path: The General Case (with negative edges) Bellman-Ford algorithm. Iteratively relax all edges |V|-1 times Running time? O(VE).
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Finding Max Flow.
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
1 WEEK 11 Graphs III Network Flow Problems A Simple Maximum-Flow Algorithm Izmir University of Economics.
Maximum Flow Chapter 26. Flow Concepts Source vertex s – where material is produced Sink vertex t – where material is consumed For all other vertices.
Algorithm Design and Analysis (ADA)
Chapter 7 May 3 Ford-Fulkerson algorithm Step-by-step walk through of an example Worst-case number of augmentations Edmunds-Karp modification Time complexity.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Data Structures & Algorithms Network Flow Richard Newman based on book by R. Sedgewick.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
Maximum Flow Problem Definitions and notations The Ford-Fulkerson method.
Instructor Neelima Gupta Edited by Divya Gaur(39, MCS '09) Thanks to: Bhavya(9), Deepika(10), Deepika Bisht(11) (MCS '09)
The Maximum Network Flow Problem
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Network Flow What is a network? Flow network and flows
Maximum Flow Chapter 26.
The Maximum Network Flow Problem
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
Maximum Flow Chapter 26.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Graph Algorithms Minimum Spanning Tree (Chap 23)
CS4234 Optimiz(s)ation Algorithms
Algorithm Design and Analysis
Lectures on Network Flows
Algorithms and Networks Hans Bodlaender
Network flow problem [Adapted from M.Chandy].
CSCI 3160 Design and Analysis of Algorithms Tutorial 8
Instructor: Shengyu Zhang
Edmonds-Karp Algorithm
Network Flows and Matching (Supplementary)
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
Network Flow and Connectivity in Wireless Sensor Networks
Lecture 10 Network flow Max-flow and Min-cut Ford-Fulkerson method
Flow Networks Topics Flow Networks Residual networks
(Push-relabel algorithms)
Richard Anderson Lecture 21 Network Flow
Network Flows and Matching (Supplementary)
Flow Networks General Characteristics Applications
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
EE5900 Advanced Embedded System For Smart Infrastructure
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
Text Book: Introduction to algorithms By C L R S
Lecture 21 Network Flow, Part 1
Maximum Flow Neil Tang 4/8/2008
Advanced Graph Homer Lee 2013/10/31.
Maximum Flow Problems in 2005.
Presentation transcript:

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

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

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”

Dominating Set 1 2 3 4 5 6 7 8 9 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 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”

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”

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

Basic Network Flow Concepts

(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

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

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

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

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: 91.503 textbook Cormen et al.

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: 91.503 textbook Cormen et al.

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

Augmenting Paths

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

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

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, 3 key ideas: augmenting paths residual networks cuts Try #3 Try #2 source: Sedgewick, Graph Algorithms

Augmenting Paths in Residual Networks

(no edges with 0 residual capacity are shown) Residual Networks min capacity on this augmenting path sources: 91.503 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)

Residual Networks sources: 91.503 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

Residual Networks sources: 91.503 textbook Cormen et al. and Prof. Pecelli Lemma 26.1. 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

Residual Networks sources: 91.503 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

Residual Networks sources: 91.503 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

Residual Networks sources: 91.503 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

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

Residual Networks sources: 91.503 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 26.2. 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. 26.2-7. Corollary 26.3. 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

Cuts

Cut Disconnects source from sink source: Sedgewick, Graph Algorithms

Cuts sources: 91.503 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…

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: 91.503 textbook Cormen et al.

Cuts Example on previous slide… sources: 91.503 textbook Cormen et al. and Prof. Pecelli Lemma 26.4. 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…

Cuts sources: 91.503 textbook Cormen et al. and Prof. Pecelli Corollary 26.5. 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

Max-Flow Min-Cut Theorem

Max-Flow Min-Cut Theorem source: 91.503 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: 91.503 textbook Cormen et al.

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

Ford-Fulkerson Max-Flow Method

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

Ford-Fulkerson: More Detail sources: 91.503 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

Ford-Fulkerson: Analysis sources: 91.503 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

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

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

Shortest Augmenting Paths Edmonds-Karp source: 91.503 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