CSC 172 DATA STRUCTURES.

Slides:



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

1 Scheduling Crossbar Switches Who do we chose to traverse the switch in the next time slot? N N 11.
CSCI 256 Data Structures and Algorithm Analysis Lecture 18 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
1 Augmenting Path Algorithm s t G: Flow value = 0 0 flow capacity.
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 
Nick McKeown Spring 2012 Maximum Matching Algorithms EE384x Packet Switch Architectures.
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)
CSC 2300 Data Structures & Algorithms April 17, 2007 Chapter 9. Graph Algorithms.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Lecture 4 Tuesday, 2/19/02 Graph Algorithms: Part 2 Network.
1 Augmenting Path Algorithm s t G: Flow value = 0 0 flow capacity.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 4 Tuesday, 10/2/01 Graph Algorithms: Part 2 Network.
Minimum Cost Flow Lecture 5: Jan 25. Problems Recap Bipartite matchings General matchings Maximum flows Stable matchings Shortest paths Minimum spanning.
Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.
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.
Here is an example that involves what is called ‘back flow’ 0 A C B D S T Arrows have already been drawn initially.
NetworkModel-1 Network Optimization Models. NetworkModel-2 Network Terminology A network consists of a set of nodes and arcs. The arcs may have some flow.
1 Scheduling Crossbar Switches Who do we chose to traverse the switch in the next time slot? N N 11.
Module 5 – Networks and Decision Mathematics Chapter 24 – Directed Graphs.
Network Flow How to solve maximal flow and minimal cut problems.
CS223 Advanced Data Structures and Algorithms 1 Maximum Flow Neil Tang 3/30/2010.
Chapter 7 April 28 Network Flow.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25.
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.
Data Structures & Algorithms Network Flow Richard Newman based on book by R. Sedgewick.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 23.
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 
1 CPSC 320: Intermediate Algorithm Design and Analysis July 14, 2014.
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)
Maximum Flow - Anil Kishore Graph Theory Basics. Prerequisites What is a Graph Directed, Weighted graphs How to traverse a graph using – Depth First Search.
Instructor Neelima Gupta Edited by Divya Gaur(39, MCS '09) Thanks to: Bhavya(9), Deepika(10), Deepika Bisht(11) (MCS '09)
5.6 Prefix codes and optimal tree Definition 31: Codes with this property which the bit string for a letter never occurs as the first part of the bit string.
Contest Algorithms January 2016 Describe the maxflow problem, explain the Ford-Fulkerson, Edmonds-Karp algorithms. Look at the mincut problem, bipartite.
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Cycle Canceling 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
BIPARTITE GRAPHS AND ITS APPLICATIONS
Lectures on Network Flows
Maximum Flow 9/13/2018 6:12 PM Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.
CSCI 3160 Design and Analysis of Algorithms Tutorial 8
December 1st – Graph Madness
Network Flows – Labelling procedure
Network Flows – Back flow
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
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
Network Flow and Connectivity in Wireless Sensor Networks
Lecture 19-Problem Solving 4 Incremental Method
Flow Networks Topics Flow Networks Residual networks
Richard Anderson Lecture 21 Network Flow
Introduction to Minimum Cost Flows
Problem Solving 4.
Lecture 5 Tuesday, 3/2/10 Graph Algorithms: Part 2
Augmenting Path Algorithm
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
Network Flow CSE 373 Data Structures.
Max Flow / Min Cut.
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
Scheduling Crossbar Switches
Lecture 21 Network Flow, Part 1
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
Augmenting Path Algorithm
Maximum Flow Neil Tang 4/8/2008
Richard Anderson Lecture 22 Network Flow
Maximum Flow Problems in 2005.
EMIS 8374 Max-Flow in Undirected Networks Updated 18 March 2008
Presentation transcript:

CSC 172 DATA STRUCTURES

FLOW

FLOW “I can go with the flow.” - Queens of the Stone Age

“Let your body go with the flow.” “I can go with the flow.” - Queens of the Stone Age “Let your body go with the flow.” - Madonna

“Let your body go with the flow.” “I can go with the flow.” - Queens of the Stone Age “Let your body go with the flow.” - Madonna “Use the flow, Luke!” - Obi-wan Kenobi

FLOW NETWORKS Three categories: Distribution problems Matching problems Cut problems

FLOW NETWORKS Distribution problems -moving objects from one place to another in a network Merchandise distribution Communication Traffic flow 1 2 3 4 5 6 7 8 9

FLOW NETWORKS Matching problems -connecting pairs Job Placement Minimum distance point matching 1 1 2 2 3 3 4 4 A B C D E

MATCHING JOB ASSINGMENTS Abe – Adobe, Apple, HP Bea – Adobe, Apple, Yahoo Cal – HP, IBM, Sun Deb – Adobe, Apple Eli – IBM, Sun, Yahoo Fay – HP, Sun, Yahoo Adobe – Abe, Bea, Deb Apple – Abe, Bea, Deb HP – Abe, Cal, Fay IBM – Cal, Eli Sun – Cal, Eli, Fay Yahoo – Bea, Eli, Fay

FLOW NETWORKS Cut problems -remove edges to break graph into two pieces Network reliability Cutting supply lines 1 1 2 2 3 3 4 4 5

FLOW NETWORKS (DEF) Flow Networks :

FLOW NETWORKS (DEF) s Flow Networks : Digraphs A B C D E t

FLOW NETWORKS (DEF) Flow Networks : Digraphs Weights on edges (capacities) 2 2 1 A B 2 2 1 2 C 2 4 D E 2 1 1 t

FLOW NETWORKS (DEF) Flow Networks : Digraphs source s Flow Networks : Digraphs Weights on edges (capacities) Two special verticies Source ; s Sink : t 2 2 1 A B 2 2 1 2 C 2 4 D E 1 2 1 t sink

CAPACITY AND FLOW Edge Capacity non-negative weights t s 2 2 1 A B 2 2 4 D E 1 2 1 1 t

CAPACITY AND FLOW Edge Capacity non-negative weights Flow 0 <= flow <= capacity flow in = flow out 2 2 1 2 1 A B 2 2 1 1 1 1 1 2 C 2 4 D 1 E 1 2 1 1 2 1 t

CAPACITY AND FLOW Edge Capacity non-negative weights Flow value = 3 s Edge Capacity non-negative weights Flow 0 <= flow <= capacity flow in = flow out Value outflow of source inflow of sink 2 2 1 2 1 A B 2 2 1 1 1 1 1 2 C 2 4 D 1 E 1 2 1 1 2 1 t value = 3

RESIDUAL GRAPH Residual = capacity - flow t s 2 2 1 2 1 A B 2 2 1 1 1 value = 3 s Residual = capacity - flow 2 2 1 2 1 A B 2 2 1 1 1 1 1 2 C 2 4 D 1 E 1 2 1 1 2 1 t value = 3

RESIDUAL CAPACITY Residual = capacity - flow t s 2 2 1 1 1 2 1 A B 1 2 value = 3 s Residual = capacity - flow 2 2 1 1 1 2 1 A B 1 2 2 1 1 1 1 1 1 2 C 1 2 4 1 4 D 1 E 1 2 1 1 1 2 1 t value = 3

RESIDUAL GRAPH Residual = capacity - flow t s 1 A 1 B 1 1 1 C 1 D 4 E

AUGMENTATION PATH Augmentation Path s Augmentation Path - a path from source to sink through the residual graph 1 A 1 B 1 1 1 C 1 D 4 E 1 t

BACKEDGE For every edge, there is a virtual reverse back edge the capacity of a back edge is the flow of the edge 2 2 1 2 1 A B 2 2 1 1 1 1 2 1 C 2 4 D 1 E 1 2 1 1 2 1 t

BACKEDGE For every edge, there is a virtual reverse back edge the capacity of a back edge is the flow of the edge (whoa!) Backedge(v,w) = flow(w,v) 2 2 2 1 1 2 1 A B 1 2 2 1 1 1 1 1 2 1 C 1 2 4 1 D 1 E 1 2 1 1 2 1 2 1 t

BACKEDGE GRAPH For every edge, there is a virtual reverse back edge the capacity of a back edge is the flow of the edge (whoa!) Backedge(v,w) = flow(w,v) 2 1 A B 1 1 1 C 1 1 D E 1 2 t

RESIDUAL GRAPH Residual(w,v) = capacity(w,v) – flow(w,v) Backedge(v,w) = flow(w,v) 2 1 1 A A 1 1 B B 1 1 1 1 1 C C 1 1 D D 1 4 E E 1 1 2 t t

Of course, in real life : There is one graph public class Edge { int v, w ; int capacity, flow; int residual, backflow; // methods }

Define Capacity Graph Flow graph residual graph (capacity – flow at each edge) back edge graph – reverse edge directions augmenting path – from s to t along non-zero capacity edges

Why all the complexity? Sometimes, in graph theory as in life, it turns out that greed leads us to sub-optimal results.

s 3 2 1 A B 3 4 2 D E 2 3 t

s 3 2 1 A B 3 4 2 D E 2 3 t

s 3 2 3 1 A B 3 4 2 3 D E 2 3 3 t

s 2 1 A B 3 1 2 D E 2 t

capacity, flow, residual, backedge 3 2 3 2 1 1 A B A B 4 3 2 3 2 4 D E D E 2 3 3 2 t t

capacity, flow, residual, backedge 3 2 3 2 3 1 1 A B A B 4 3 2 3 2 4 3 D E D E 2 3 3 3 2 t t

capacity, flow, residual, backedge 3 2 2 3 3 1 1 A B A B 1 3 2 3 2 4 3 3 D E D E 2 3 3 2 3 t t

capacity, flow, residual, backedge 3 2 2 3 3 1 1 A B A B 1 3 2 3 2 4 3 3 D E D E 2 3 3 2 3 t t

capacity, flow, residual, backedge 3 2 2 3 2 3 1 1 A B A B 1 3 2 2 2 3 2 4 1 3 D E D E 2 3 2 3 2 3 t t

capacity, flow, residual, backedge 3 2 3 2 3 1 2 1 A B A B 3 3 2 2 2 3 2 2 4 1 1 D E D E 2 3 2 2 3 3 t t

capacity, flow, residual, backedge 3 2 3 2 3 1 2 1 A B A B 3 3 2 2 2 3 2 2 4 1 1 D E D E 2 3 2 2 3 3 t t