Network Flow. November 23, CMPE 250 Graphs- Network Flow November 23, / 31

Similar documents
Copyright 2007 Pearson Addison-Wesley. All rights reserved. A. Levitin Introduction to the Design & Analysis of Algorithms, 2 nd ed., Ch.

Jessica Su (some parts copied from CLRS / last quarter s notes)

COT 6936: Topics in Algorithms! Giri Narasimhan. ECS 254A / EC 2443; Phone: x3748

Lecture 11: Maximum flow and minimum cut

Network Flow. The network flow problem is as follows:

Maximum flows & Maximum Matchings

Maximum Flow. Flow Networks. Flow Networks Ford-Fulkerson Method Edmonds-Karp Algorithm Push-Relabel Algorithms. Example Flow Network

CS483 Analysis of Algorithms Lecture 09 Linear Programming 01

Chapter 5 Graph Algorithms Algorithm Theory WS 2012/13 Fabian Kuhn

Matchings, Ramsey Theory, And Other Graph Fun

Graphs and Network Flows IE411. Lecture 13. Dr. Ted Ralphs

Graph Theory: Matchings and Factors

Network Flow I. Lecture Overview The Network Flow Problem

Tutorial for Algorithm s Theory Problem Set 5. January 17, 2013

Source. Sink. Chapter 10: Iterative Programming Maximum Flow Problem. CmSc250 Intro to Algorithms

Maximum Flow Algorithms

Theorem 3.1 (Berge) A matching M in G is maximum if and only if there is no M- augmenting path.

Algorithm Circle Extra Lecture: Solving the Assignment Problem with Network Flow

Homework 3 Solutions

Problem set 2. Problem 1. Problem 2. Problem 3. CS261, Winter Instructor: Ashish Goel.

Matching and Covering

1 The Arthur-Merlin Story

Outline: Finish uncapacitated simplex method Negative cost cycle algorithm The max-flow problem Max-flow min-cut theorem

Graph Theory II. Po-Shen Loh. June edges each. Solution: Spread the n vertices around a circle. Take parallel classes.

CSE 417 Network Flows (pt 4) Min Cost Flows

CPSC W1: Midterm #1

Lecture 14: Linear Programming II

LECTURES 3 and 4: Flows and Matchings

Greedy Homework Problems

COMP 251 Winter 2017 Online quizzes with answers

CPSC W1: Midterm #1 (Group Version) Thu

CS261: Problem Set #2

Notes for Lecture 20

Discrete Optimization Lecture-11

Lecture 7: Bipartite Matching

CS612 Algorithms for Electronic Design Automation

Assignment and Matching

Graph Algorithms Matching

Sources for this lecture. 3. Matching in bipartite and general graphs. Symmetric difference

MC302 GRAPH THEORY Thursday, 10/24/13

Lecture 10,11: General Matching Polytope, Maximum Flow. 1 Perfect Matching and Matching Polytope on General Graphs

Today. Maximum flow. Maximum flow. Problem

CPSC 320 Midterm #1. February 4, 2015

Chapter 7. Network Flow. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Lecture 3: Graphs and flows

Tutorial 4: Flow Artificial Intelligence

1. To reduce the probability of having any collisions to < 0.5 when hashing n keys, the table should have at least this number of elements.

Discrete Mathematics and Probability Theory Summer 2016 Dinh, Psomas, and Ye HW 2

GRAPH DECOMPOSITION BASED ON DEGREE CONSTRAINTS. March 3, 2016

CSC 8301 Design & Analysis of Algorithms: Linear Programming

Network Design and Optimization course

Lecture and notes by: Sarah Fletcher and Michael Xu November 3rd, Multicommodity Flow

Matchings and Covers in bipartite graphs

Solving problems on graph algorithms

Computational Methods in IS Research Fall Graph Algorithms Network Flow Problems

Cuts, Connectivity, and Flow

CSE 417 Network Flows (pt 3) Modeling with Min Cuts

5 Matchings in Bipartite Graphs and Their Applications

Transportation Planning: The maximum flow problem

1. Let n and m be positive integers with n m. a. Write the inclusion/exclusion formula for the number S(n, m) of surjections from {1, 2,...

Minimum Cost Edge Disjoint Paths

Datenstrukturen & Algorithmen Solution of Sheet 11 FS 14

Problem Set 7 Solutions

Graphs. Edges may be directed (from u to v) or undirected. Undirected edge eqvt to pair of directed edges

Interlude: Problem Solving

Bipartite Matching & the Hungarian Method

Final Exam. Jonathan Turner 5/12/2010. CS 542 Advanced Data Structures and Algorithms

and 6.855J March 6, Maximum Flows 2

APPLIED MECHANISM DESIGN FOR SOCIAL GOOD

On Galvin s Theorem and Stable Matchings. Adam Blumenthal

Stable Flows over Time

COMP4128 Programming Challenges

Balls Into Bins Model Occupancy Problems

NETWORK OPTIMIZATION MODELS

Matchings. Examples. K n,m, K n, Petersen graph, Q k ; graphs without perfect matching. A maximal matching cannot be enlarged by adding another edge.

Network flows and Menger s theorem

Mathematics for Decision Making: An Introduction. Lecture 18

CS/COE 1501 cs.pitt.edu/~bill/1501/ Network Flow

CS 758/858: Algorithms

Network Flows. 1. Flows deal with network models where edges have capacity constraints. 2. Shortest paths deal with edge costs.

Matching Theory. Amitava Bhattacharya

Network Flow. By: Daniel Pham, Anthony Huber, Shaazan Wirani

Module 7. Independent sets, coverings. and matchings. Contents

Partitioning. Course contents: Readings. Kernighang-Lin partitioning heuristic Fiduccia-Mattheyses heuristic. Chapter 7.5.

Applications of Linear Programming

CLASS: II YEAR / IV SEMESTER CSE CS 6402-DESIGN AND ANALYSIS OF ALGORITHM UNIT I INTRODUCTION

The vertex set is a finite nonempty set. The edge set may be empty, but otherwise its elements are two-element subsets of the vertex set.

Preflow-Push Algorithm

Math and Marriage - Don t Call a Lawyer Yet!

Review for Midterm Exam

Matchings. Saad Mneimneh

Implementing Algorithms

Lecture 3: Totally Unimodularity and Network Flows

Student Name and ID Number. MATH 3012, Quiz 3, April 16, 2018, WTT

5105 BHARATHIDASAN ENGINEERING COLLEGE

CS261: Problem Set #1

GRAPH THEORY: NETWORK FLOW Vrushali Manohar Asst Prof, IFIM College, Bangalore

s-t Graph Cuts for Binary Energy Minimization

GRAPH THEORY and APPLICATIONS. Matchings

Parametric Maximum Flow Problem: Techniques and Algorithms. Deepika Sareen, Dr Deepak Garg. Thapar University, Patiala

Transcription:

Network Flow November 23, 2016 CMPE 250 Graphs- Network Flow November 23, 2016 1 / 31

Types of Networks Internet Telephone Cell Highways Rail Electrical Power Water Sewer Gas... CMPE 250 Graphs- Network Flow November 23, 2016 2 / 31

Maximum Flow Problem How can we maximize the flow in a network from a source or set of sources to a destination or set of destinations? The first efficient algorithm for finding the maximum flow was conceived by two Computer Scientists, named Ford and Fulkerson. CMPE 250 Graphs- Network Flow November 23, 2016 3 / 31

Network Flow A Network is a directed graph G Edges represent pipes that carry flow Each edge < u, v > has a maximum capacity c <u,v> There is a source node s in which flow arrives There is a sink node t out which flow leaves CMPE 250 Graphs- Network Flow November 23, 2016 4 / 31

Network Flow The network flow problem is as follows: Given a connected directed graph G with non-negative integer weights, (where each edge stands for the capacity of that edge), Two different vertices, s and t, called the source and the sink, such that the source only has out-edges and the sink only has in-edges, Find the maximum amount of some commodity that can flow through the network from source to sink. Each edge stands for the capacity of that edge. CMPE 250 Graphs- Network Flow November 23, 2016 5 / 31

Network Flow One way to imagine the situation is imagining each edge as a pipe that allows a certain flow of a liquid per second. The source is where the liquid is pouring from, and the sink is where it ends up. Each edge weight specifies the maximal amount of liquid that can flow through that pipe per second. Given that information, what is the most liquid that can flow from source to sink per second, in the steady state? Each edge stands for the capacity of that edge. CMPE 250 Graphs- Network Flow November 23, 2016 6 / 31

Network Flow This graph contains the capacities of each edge in the graph. An example of a flow in the graph. The flow of the network is defined as the flow from the source, or into the sink. For the situation above, the network flow is 23. CMPE 250 Graphs- Network Flow November 23, 2016 7 / 31

Network Flow Rules Capacities Flow The Conservation Rule: In order for the assignment of flows to be valid, we must have the sum of flow coming into a vertex equal to the flow coming out of a vertex, for each vertex in the graph except the source and the sink. The Capacity Rule: Also, each flow must be less than or equal to the capacity of the edge. The flow of the network is defined as the flow from the source, or into the sink. For the situation above, the network flow is 23. CMPE 250 Graphs- Network Flow November 23, 2016 8 / 31

Network Flow In order to determine the maximum flow of a network, we will use the following terms: Residual capacity is simply an edge s unused capacity. Initially none of the capacities will have been used, so all of the residual capacities will be just the original capacity. Using the notation: used/capacity. Residual Capacity: capacity used. CMPE 250 Graphs- Network Flow November 23, 2016 9 / 31

Network Flow Residual capacity of a path the minimum of the residual capacities of the edges on that path, which will end up being the max excess flow we can push down that path. Augmenting path defined as one where you have a path from the source to the sink where every edge has a non-zero residual capacity. Using the notation: used/unused. Residual Capacity: unused used. CMPE 250 Graphs- Network Flow November 23, 2016 10 / 31

Ford-Fulkerson Algorithm While there exists an augmenting path Add the appropriate flow to that augmenting path So we re going to arbitrarily choose an the augmenting path s, c, d, t in the graph below: And add the flow to that path. Residual capacity of a path the minimum of the residual capacities of the edges on that path. 4 in this case, which is the limiting factor for this path s flow. CMPE 250 Graphs- Network Flow November 23, 2016 11 / 31

Ford-Fulkerson Algorithm While there exists an augmenting path Add the appropriate flow to that augmenting path Choose another augmenting path (one where you have a path from the source to the sink where every edge has a non-zero residual capacity.) s, a, b, t Residual capacity of a path the minimum of the residual capacities of the edges on that path. 12 in this case, which is the limiting factor for this path s flow. CMPE 250 Graphs- Network Flow November 23, 2016 12 / 31

Ford-Fulkerson Algorithm While there exists an augmenting path Add the appropriate flow to that augmenting path Choose another augmenting path (one where you have a path from the source to the sink where every edge has a non-zero residual capacity.) s, c, d, b, t Residual capacity of a path the minimum of the residual capacities of the edges on that path. 7 in this case, which is the limiting factor for this path s flow. CMPE 250 Graphs- Network Flow November 23, 2016 13 / 31

Ford-Fulkerson Algorithm While there exists an augmenting path Add the appropriate flow to that augmenting path Are there any more augmenting paths? No! We re done The maximum flow = 19 + 4 = 23 CMPE 250 Graphs- Network Flow November 23, 2016 14 / 31

Cuts of Flow Networks A cut(s, T ) of a flow network is a partition of V into S and T = V S such that s S and t T. CMPE 250 Graphs- Network Flow November 23, 2016 15 / 31

The Net Flow through a Cut (S,T) f (S, T ) = u S,v T f (u, v) f (S, T ) = 12 4 + 11 = 19 CMPE 250 Graphs- Network Flow November 23, 2016 16 / 31

The Capacity of a Cut (S,T) c(s, T ) = u S,v T c(u, v) c(s, T ) = 12 + 0 + 14 = 26 CMPE 250 Graphs- Network Flow November 23, 2016 17 / 31

Augmenting Paths example The maximum possible flow through the cut = 12 + 7 + 4 = 23 The network has a capacity of at most 23. This is called a minimum cut. CMPE 250 Graphs- Network Flow November 23, 2016 18 / 31

Net Flow of a Network The net flow across any cut is the same and equal to the flow of the network f. CMPE 250 Graphs- Network Flow November 23, 2016 19 / 31

Bounding the Network Flow The value of any flow f in a flow network G is bounded from above by the capacity of any cut of G. CMPE 250 Graphs- Network Flow November 23, 2016 20 / 31

Max-Flow Min-Cut Theorem If f is a flow in a flow network G = (V, E), with source s and sink t, then the following conditions are equivalent: 1 f is a maximum flow in G. 2 The residual network G f contains no augmented paths. 3 f = f (S, T ) for some cut (S, T ) (a min-cut). CMPE 250 Graphs- Network Flow November 23, 2016 21 / 31

Bipartite Matching Assume that we have a set of people L and set of jobs R. Each person can do only some of the jobs. We can model this as a bipartite graph. CMPE 250 Graphs- Network Flow November 23, 2016 22 / 31

Bipartite Matching A matching provides an assignment of people to tasks. We want to have as many tasks done as possible. So, we want a maximum matching: one that contains as many edges as possible. The matching on the right is not maximum. CMPE 250 Graphs- Network Flow November 23, 2016 23 / 31

Maximum Bipartite Matching Maximum Bipartite Matching: Given a bipartite graph G = (L R, E), find an S L R that is a matching and is as large as possible. S is a perfect matching if every vertex is matched. CMPE 250 Graphs- Network Flow November 23, 2016 24 / 31

Solution by Transformation Given an instance of bipartite matching, Create an instance of network flow. The solution to the network flow problem can be used to find the solution to the bipartite matching. CMPE 250 Graphs- Network Flow November 23, 2016 25 / 31

Transforming Bipartite Matching to Network Flow CMPE 250 Graphs- Network Flow November 23, 2016 26 / 31

Transforming Bipartite Matching to Network Flow Direct the edges from L to R. CMPE 250 Graphs- Network Flow November 23, 2016 27 / 31

Transforming Bipartite Matching to Network Flow Add new vertices s and t. Add an edge from s to every vertex in L. Add an edge from every vertex in R to t. CMPE 250 Graphs- Network Flow November 23, 2016 28 / 31

Transforming Bipartite Matching to Network Flow Make all the capacities 1. Solve maximum network flow problem on this new graph G. The edges used in the maximum network flow will correspond to the largest possible matching! CMPE 250 Graphs- Network Flow November 23, 2016 29 / 31

The stable marriage problem The stable marriage problem is not a network flow problem, but it is a matching problem. The scenario is as follows: We are given two sets,v M and V F (male and female) of the same size. Also, every man v V m ranks every woman u V F and every woman u V F ranks every man in V M. We will write u < v u if v would rather marry u than u. The stable marriage problem is to find a matching E V M V F such that if (v, u) and (w, z) are in E, then either u < v z or w < z v. CMPE 250 Graphs- Network Flow November 23, 2016 30 / 31

Solution The Gale-Shapley algorithm is a solution to the stable marriage problem that involves a number of rounds. Heuristically, at each round every unengaged man proposes to his most preferred woman that he has not already proposed to. If this woman is unengaged or engaged to someone she prefers less than her new suitor, she breaks off her current engagement and accepts the new proposal. These iterations continue until everybody is engaged. It can be shown that at this point we have a solution to the stable marriage problem. CMPE 250 Graphs- Network Flow November 23, 2016 31 / 31