Maximum Flow and Minimum Spanning Tree Problem Difficulty Another Puzzler 10 B: Graph Algorithms IV CS1102S: Data Structures and Algorithms Martin Henz March 27, 2009 Generated on Friday 26 th March, 2010, 10:59 CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 1
Maximum Flow and Minimum Spanning Tree Problem Difficulty Another Puzzler Maximum Flow and Minimum Spanning Tree 1 Problem Difficulty 2 Another Puzzler 3 CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 2
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Maximum Flow and Minimum Spanning Tree 1 Maximum Flow Minimum Spanning Tree Problem Difficulty 2 Another Puzzler 3 CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 3
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Maximum Flow Interpretation of weights Every weight of an edge ( v , w ) represents a capacity of a flow passing from v to w . CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 4
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Maximum Flow Interpretation of weights Every weight of an edge ( v , w ) represents a capacity of a flow passing from v to w . Maximum Flow Given two vertices s and t , compute the maximal flow achievable from s to t . CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 5
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Example Graph and Maximum Flow CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 6
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Idea Identify an augmenting path a path that has a feasible flow CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 7
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Idea Identify an augmenting path a path that has a feasible flow Add path to flow graph keeping track of a flow that is already achieved CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 8
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Idea Identify an augmenting path a path that has a feasible flow Add path to flow graph keeping track of a flow that is already achieved Remove path from residual graph keeping track of the remaining flow that can still be exploited CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 9
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Example: Initial Setup CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 10
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Example Run CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 11
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Example Run CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 12
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Example Run CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 13
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Counterexample: Suboptimal Solution CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 14
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Idea Allow algorithm to change its mind Add reverse edge to residual graph, allowing a flow back in the opposite direction. CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 15
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Idea Allow algorithm to change its mind Add reverse edge to residual graph, allowing a flow back in the opposite direction. Consequence This means that later, we can exploit an original flow which has been utilized already in the current flow graph, for a new augmenting path. CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 16
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Example CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 17
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Runtime Analysis Assumption Edge weights are integers CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 18
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Runtime Analysis Assumption Edge weights are integers Each augmenting path makes “progress” adding a flow of at least 1 to the flow graph. CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 19
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Runtime Analysis Assumption Edge weights are integers Each augmenting path makes “progress” adding a flow of at least 1 to the flow graph. Finding augmenting paths can be done in O ( N ) , using unweighted shortest path algorithm CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 20
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Runtime Analysis Assumption Edge weights are integers Each augmenting path makes “progress” adding a flow of at least 1 to the flow graph. Finding augmenting paths can be done in O ( N ) , using unweighted shortest path algorithm Overall O ( f · | E | ) where f is the maximum flow CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 21
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Bad case CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 22
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Minimum Spanning Tree Problem Input Undirected weighted connected graph G CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 23
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Minimum Spanning Tree Problem Input Undirected weighted connected graph G Spanning tree Tree that contains all of G ’s vertices and only edges from G CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 24
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Minimum Spanning Tree Problem Input Undirected weighted connected graph G Spanning tree Tree that contains all of G ’s vertices and only edges from G Minimum spanning tree Spanning tree whose sum of edge weights is minimal CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 25
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler An Example Graph and its MST CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 26
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Algorithm Idea Similar to Dijkstra’s Algorithm Start “growing” the MST at arbitrary vertex. CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 27
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Algorithm Idea Similar to Dijkstra’s Algorithm Start “growing” the MST at arbitrary vertex. At each step, add an edge to MST with smallest weight. CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 28
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Algorithm Idea Similar to Dijkstra’s Algorithm Start “growing” the MST at arbitrary vertex. At each step, add an edge to MST with smallest weight. Implementation Keep edges from “known” to “unknown” vertices in a priority queue. CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 29
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Example CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 30
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Runtime Analysis Without priority queue O ( | V | 2 ) CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 31
Maximum Flow and Minimum Spanning Tree Maximum Flow Problem Difficulty Minimum Spanning Tree Another Puzzler Runtime Analysis Without priority queue O ( | V | 2 ) With priority queue O ( | E | log | V | ) CS1102S: Data Structures and Algorithms 10 B: Graph Algorithms IV 32
Recommend
More recommend