32
UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Lecture 4 Lecture 4 Tuesday, 2/19/02 Tuesday, 2/19/02 Graph Algorithms: Part 2 Graph Algorithms: Part 2 Network Flows, Case Study Network Flows, Case Study

UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Spring, 2001

  • Upload
    sovann

  • View
    33

  • Download
    2

Embed Size (px)

DESCRIPTION

UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Spring, 2001. Lecture 4 Tuesday, 2/19/02 Graph Algorithms: Part 2 Network Flows, Case Study. Network Flow. Chapter 26. Basic Network Flow Concepts. Network Flow. edge weights. source. - PowerPoint PPT Presentation

Citation preview

Page 1: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

UMass Lowell Computer Science 91.503

Analysis of Algorithms Prof. Karen Daniels

Spring, 2001

UMass Lowell Computer Science 91.503

Analysis of Algorithms Prof. Karen Daniels

Spring, 2001

Lecture 4Lecture 4Tuesday, 2/19/02Tuesday, 2/19/02

Graph Algorithms: Part 2Graph Algorithms: Part 2Network Flows, Case Study Network Flows, Case Study

Page 2: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Network Flow Network Flow

Chapter 26Chapter 26

Page 3: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Basic Network Flow Concepts

Basic Network Flow Concepts

Page 4: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Network FlowNetwork Flow

source: Sedgewick, Graph Algorithmssource: Sedgewick, Graph Algorithms

weighted network

edge weights

Goal:Goal: compute second set of compute second set of edge weights <= capacities. edge weights <= capacities.

flow

direction

source

sink

flow in = flow out flow in = flow out

(except at source, sink) (except at source, sink)

Page 5: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Network Flow ApplicationsNetwork 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 Algorithmssource: Sedgewick, Graph Algorithms

Page 6: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Network Flow Applications (continued)Network Flow Applications (continued)

Matching ProblemsMatching Problems network represents ways to connect verticesnetwork represents ways to connect vertices goal: choose connections to goal: 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 Algorithmssource: Sedgewick, Graph Algorithms

Page 7: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Network Flow Applications(continued)Network Flow Applications(continued)

Cut ProblemsCut Problems remove edges to cut network into >= 2 piecesremove edges to cut network into >= 2 pieces examples:examples:

network reliabilitynetwork reliability cutting supply linescutting supply lines

source: Sedgewick, Graph Algorithmssource: Sedgewick, Graph Algorithms

Page 8: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Flow DefinitionsFlow 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 every vertex is on some path from source s to

sink tsink t G is connectedG is connected |E| >= |V| - 1|E| >= |V| - 1

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

Page 9: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Flow PropertiesFlow 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 net flow entering vertex v:positive net flow entering vertex v:

positive net flow entering a vertex other than source or sink must = positive positive net flow entering a vertex other than source or sink must = positive net flow leaving the vertexnet flow leaving the vertex

Value of a flow f is total net flow Value of a flow f is total net flow out of sourceout of source::

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

),(),(, vucvufVvu

),(),(, uvfvufVvu

VvvuftsVu 0),(},{

Vvvsff ),(||

0),(

),(vuf

Vu vuf

VuvuftsVv 0),(},{

Page 10: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Flow Properties (continued)Flow Properties (continued)

Lemma 26.1Lemma 26.1 Let G=(V,E) be a flow network, and let f be a flow Let G=(V,E) be a flow network, and let f be a flow

in G. Then:in G. Then:

Implicit summation notation:Implicit summation notation:

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

0),( XXfVX

),(),(, XYfYXfVYX

),(),(),(0,, ZYfZXfZYXfYXwithVZYX

),(),(),(0,, YZfXZfYXZfYXwithVZYX

Exercise: showExercise: show ),(|| tVff

Xx Yy

yxfYXf ),(),(

Page 11: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

source: Sedgewick, Graph Algorithmssource: 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 left set from right set

x = amount of flow into right set from left set

EQUILIBRIUM requires

A + x = B + y C + y = D + x

A + C = B + D

Page 12: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Controlling Network FlowControlling Network Flow

source: Sedgewick, Graph Algorithmssource: Sedgewick, Graph Algorithms

open switches along path < 0,1,3,5>open switches along path < 0,1,3,5> open switches along path < 0,2,4,5>open switches along path < 0,2,4,5>

change switch at 1 to redirect change switch at 1 to redirect flow to fill 1-4; add flow on flow to fill 1-4; add flow on < 0,2,3,5 > (maxflow results)< 0,2,3,5 > (maxflow results)

Page 13: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Augmenting Paths

Augmenting Paths

Page 14: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Augmenting Flow on a PathAugmenting Flow on a Path

source: Sedgewick, Graph Algorithmssource: Sedgewick, Graph Algorithms

increase flow in <0,2>

2

2

2

2

increase flow in <2,3> decrease flow in <1,3>

divert to <1,4>,<4,5>

11

1

1

2

flow increases from 3 to 4

Page 15: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Augmenting Path SequencesAugmenting Path Sequences

source: Sedgewick, Graph Algorithmssource: Sedgewick, Graph Algorithms

Page 16: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Residual Networks

Residual Networks

Page 17: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Residual NetworksResidual Networks

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

flow network G and flow f

residual network Gf

and augmenting path

augmented flow in G

augmented flow in Gf

min capacity on augmenting path

Page 18: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Residual NetworksResidual Networks

source: Sedgewick, Graph Algorithmssource: Sedgewick, Graph Algorithms

Page 19: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Cuts

Cuts

Page 20: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

s-t Cuts-t Cut

source: Sedgewick, Graph Algorithmssource: Sedgewick, Graph Algorithms

Disconnects source from sinkDisconnects source from sink

Page 21: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

MaxFlow MinCut TheoremMaxFlow MinCut Theorem

If If ff is a flow in a flow network G=(V,E) is a flow in a flow network G=(V,E) with source with source ss and sink and sink tt, then, equivalently:, then, equivalently: 1. 1. ff is a maximum flow in G is a maximum flow in G 2. The residual network G2. The residual network Gff contains no contains no

augmenting pathsaugmenting paths 3. |3. |ff| = c(S,T) for some cut (S,T) of G| = c(S,T) for some cut (S,T) of G

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

Page 22: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

MaxFlow MinCut TheoremProof LayoutMaxFlow MinCut TheoremProof Layout

Lemma 26.1Lemma 26.1Lemma 26.2Lemma 26.2Lemma 26.3Lemma 26.3

Corollary 26.4Corollary 26.4Lemma 26.5Lemma 26.5

Corollary 26.6Corollary 26.6

Eq 26.6Eq 26.6 Eq 26.4Eq 26.4

MaxFlow MinCutMaxFlow MinCut

(3) -> (1)(3) -> (1)

(1) -> (2)(1) -> (2)

(2) -> (3)(2) -> (3)

Theorem 26.7Theorem 26.7

Page 23: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Ford-Fulkerson MaxFlow Method

Ford-Fulkerson MaxFlow Method

Page 24: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

General ApproachGeneral Approach

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

Page 25: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

With Residual NetworksWith Residual Networks

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

Page 26: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

Page 27: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

AnalysisAnalysis

source: 91.503 textbook Cormen et al.source: 91.503 textbook Cormen et al.

Time depends Time depends on methodon methodtermination?termination?

(E) time(E) time

( |( |maxmax f f | ) | ) iterations, iterations, assuming integral assuming integral capacitiescapacities

Each iteration of while loop can be executed in O(E) Each iteration of while loop can be executed in O(E) time time = time to find path in residual network using BFS or DFS= time to find path in residual network using BFS or DFS

Total time Total time = = ( E |( E |maxmax f f | ) | ) assuming integral capacitiesassuming integral capacities

Page 28: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Shortest Augmenting PathsEdmonds-KarpShortest Augmenting PathsEdmonds-Karp

source: Sedgewick, Graph Algorithmssource: Sedgewick, Graph Algorithms

Page 29: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Shortest Augmenting PathsEdmonds-KarpShortest Augmenting PathsEdmonds-Karp

Time is in O(VETime is in O(VE22):): 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(VE)Number of iterations is in O(VE)

Shortest-path distance in residual network increases Shortest-path distance in residual network increases monotonically with each flow augmentationmonotonically with each flow augmentation

Total number of augmentations is in O(VE)Total number of augmentations is in O(VE) Proof Sketch:Proof Sketch:

Edge in residual network is critical on augmenting path if residual Edge in residual network is critical on augmenting path if residual capacity of path is residual capacity of (u,v)capacity of path is residual capacity of (u,v)

Critical edge disappears from residual networkCritical edge disappears from residual network Critical edge reappears Critical edge reappears onlyonly if net flow from u to v is decreased; if net flow from u to v is decreased;

happens only if (v,u) appears later on another augmenting pathhappens only if (v,u) appears later on another augmenting path From time (u,v) becomes critical to time it next becomes critical, From time (u,v) becomes critical to time it next becomes critical,

distance of u from source increases by >= 2distance 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

Page 30: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Graph Algorithms Graph Algorithms

Research Case StudyResearch Case Study

Page 31: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Case Study LiteratureWu, Li [1999]Case Study LiteratureWu, Li [1999]

Title Oncalculatingconnecteddominatingset forefficientrouting in adhoc wirelessnetworks

Source Conf:Workshop onDiscrete Algand Methodsfor MOBILEComputing&Communications

ApplicationAreas

dynamicwirelesscommunications

InputObjects

2D pointsrepresentinghosts

AspectDimensionality

2D

Problem/Task

dominatingset

Theory?Implementation?

someexperiments

ADTs &DataStructures

undirectedgraph

AlgorithmicParadigms&Techniques

distributed;heuristic

Math Topics graph theory:dominatingset

Page 32: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels  Spring, 2001

Case Study LiteratureWu, Li [1999]Case Study LiteratureWu, Li [1999]

Board work Board work In-class exerciseIn-class exercise