CSC 2300 Data Structures & Algorithms April 17, 2007 Chapter 9. Graph Algorithms.

Slides:



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

Graph Theory Arnold Mesa. Basic Concepts n A graph G = (V,E) is defined by a set of vertices and edges v3 v1 v2Vertex (v1) Edge (e1) A Graph with 3 vertices.
§3 Shortest Path Algorithms Given a digraph G = ( V, E ), and a cost function c( e ) for e  E( G ). The length of a path P from source to destination.
CSC 2300 Data Structures & Algorithms April 13, 2007 Chapter 9. Graph Algorithms.
1 Review of some graph algorithms Graph G(V,E) (Chapter 22) –Directed, undirected –Representation Adjacency-list, adjacency-matrix Breadth-first search.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley. All rights reserved.
Introduction To Algorithms CS 445 Discussion Session 8 Instructor: Dr Alon Efrat TA : Pooja Vaswani 04/04/2005.
The Maximum Network Flow Problem. CSE Network Flows.
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
Nick McKeown Spring 2012 Maximum Matching Algorithms EE384x Packet Switch Architectures.
1 Spanning Trees Lecture 20 CS2110 – Spring
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Chapter 11 Network Models. What You Need to Know For each of the three models: –What is the model? (what are given and what is to calculate) –What is.
Prim’s Algorithm and an MST Speed-Up
CSC 2300 Data Structures & Algorithms April 3, 2007 Chapter 9. Graph Algorithms.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
The Shortest Path Problem
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
TECH Computer Science Graph Optimization Problems and Greedy Algorithms Greedy Algorithms  // Make the best choice now! Optimization Problems  Minimizing.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.
Analysis of Algorithms
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Greedy methods Prudence Wong
Maximum Flow Chapter 26.
Algorithms: Design and Analysis Summer School 2013 at VIASM: Random Structures and Algorithms Lecture 3: Greedy algorithms Phan Th ị Hà D ươ ng 1.
Lecture 5: Network Flow Algorithms Single-Source Shortest-Path (SSSP) (Dijkstra's Algorithm) Max Flow - Min Cut (Ford-Fulkerson) Job Sequencing.
Network Flow How to solve maximal flow and minimal cut problems.
1 CPSC 320: Intermediate Algorithm Design and Analysis July 11, 2014.
Prims’ spanning tree algorithm Given: connected graph (V, E) (sets of vertices and edges) V1= {an arbitrary node of V}; E1= {}; //inv: (V1, E1) is a tree,
Single Source Shortest-Path: The General Case (with negative edges) Bellman-Ford algorithm. Iteratively relax all edges |V|-1 times Running time? O(VE).
Lecture 19 Greedy Algorithms Minimum Spanning Tree Problem.
1 WEEK 11 Graphs III Network Flow Problems A Simple Maximum-Flow Algorithm Izmir University of Economics.
CS223 Advanced Data Structures and Algorithms 1 Maximum Flow Neil Tang 3/30/2010.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25.
1 Network Flow CSC401 – Analysis of Algorithms Chapter 8 Network Flow Objectives: Flow networks –Flow –Cut Maximum flow –Augmenting path –Maximum flow.
Fall 2003Maximum Flow1 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 
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Prims Algorithm for finding a minimum spanning tree
ENGM 631 Maximum Flow Solutions. Maximum Flow Models (Flow, Capacity) (0,3) (2,2) (5,7) (0,8) (3,6) (6,8) (3,3) (4,4) (4,10)
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
Minimum Spanning Trees
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
Chapter 9 : Graphs Part II (Minimum Spanning Trees)
Minimum Spanning Tree Chapter 13.6.
Richard Anderson Lecture 23 Network Flow
Lecture 22 Network Flow, Part 2
CSCI 3160 Design and Analysis of Algorithms Tutorial 8
Minimum Spanning Trees and Shortest Paths
Topological Sort (topological order)
Short paths and spanning trees
Maximum Flow Solutions
Minimum Spanning Trees
Connected Components Minimum Spanning Tree
Network Flow 2016/04/12.
Edmonds-Karp Algorithm
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
Richard Anderson Lecture 21 Network Flow
Problem Solving 4.
Fundamental Data Structures and Algorithms
Fundamental Structures of Computer Science II
離散數學 DISCRETE and COMBINATORIAL MATHEMATICS
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
Lecture 21 Network Flow, Part 1
CSC 380: Design and Analysis of Algorithms
Maximum Flow Neil Tang 4/8/2008
The Greedy Approach Young CS 530 Adv. Algo. Greedy.
Prim’s algorithm for minimum spanning trees
Lecture 22 Network Flow, Part 2
Richard Anderson Lecture 22 Network Flow
Presentation transcript:

CSC 2300 Data Structures & Algorithms April 17, 2007 Chapter 9. Graph Algorithms

Today Network Flow Minimum Spanning Tree  Prim’s Algorithm

Network Flow Given a directed graph G=(V,E) with edge capacities c vw. Examples: amount of water that flow through a pipe, or amount of traffic on a street between two intersections. Also given two vertices: source s and sink t. Goal: determine the maximum amount of flow that can pass from s to t.

Example A graph and its maximum flow:

Procedure Start with our graph G. Construct a flow graph G f, which gives the flow that has been attained at the current stage. Initially, all edges in G f have no flow. Also construct a graph G r, called the residual graph. Each edge of G r tells us how much more flow can be added.

Initial Stage Graphs G, G f, and G r :

Stage 2 Two units of flow are added along s, b, d, t:

Stage 3 Two units of flow are added along s, a, c, t:

Stage 4 One unit of flow added along s, a, d, t: Algorithm terminates with correct solution.

Greedy Algorithm We have described a greedy algorithm, which does not always work. Here is an example: Algorithm terminates with suboptimal solution.

Improve Algorithm How to make the algorithm work? Allow it to change its mind! For every edge (v,w) with flow f vw in the flow graph, we will add an edge in the residual graph (w,v) of capacity f vw. What are we doing? We are allowing the algorithm to undo its decisions by sending flow back in the opposite direction.

Augmenting Path Old: New:

Improved Algorithm Two units of flow are added along s, b, d, a, c, t: Algorithm terminates with correct solution.

Algorithm Always Works? Theorem. If the edge capacities are rational numbers, then the improved algorithm always terminates with a maximal flow. What are rational numbers?

Running Time Say that the capacities are all integers and the maximal flow is f. Each augmenting flow increases the flow value by at least one. How many stages? Augmenting path can be found by which algorithm? Unweighted shortest path. Total time? O( f |E| ).

Bad Case This is a classic bad case for augmenting: The maximum flow is easily seen by inspection. Random augmentations could go along a path that includes (a,b). What is the worst case for number of augmentations? 2,000,000.

Remedy How to get around problem on previous slide? Choose the augmenting path that gives the largest increase in flow. Which algorithm? Modify the Dijkstra’s algorithm that solves a weighted shortest-path problem.

Minimum Spanning Tree

Example

Second Example A graph and its minimum spanning tree:

Prim’s Algorithm Outline:

Prim’s Algorithm

Prim’s Algorithm – Tables

Another Algorithm Can you name another algorithm that is very similar to Prim’s algorithm? Dijkstra’s algorithm. What is the major difference?

Running Time Without heaps? O( |V| 2 ). Optimal for dense graphs. With heaps? O( |E| log|V| ). Good for sparse graphs.