Network Flows Chun-Ta, Yu Graduate Institute Information Management Dept. National Taiwan University.

Slides:



Advertisements
Similar presentations
Lecture 5 Graph Theory. Graphs Graphs are the most useful model with computer science such as logical design, formal languages, communication network,
Advertisements

15.082J & 6.855J & ESD.78J October 14, 2010 Maximum Flows 2.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Chapter 5 Shortest Paths: Label-Correcting Algorithms
Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm.
Data Structures Using C++
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 
Lectures on Network Flows
Chapter 7 Maximum Flows: Polynomial Algorithms
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
Chapter 26 of CLSR Bipartite Matching By Dr. M. Sakalli, Sources: Levitin and many other CSE, Marmara Univ. May/2009.
Network Optimization Models: Maximum Flow Problems In this handout: The problem statement Solving by linear programming Augmenting path algorithm.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
Minimum Cost Flow Lecture 5: Jan 25. Problems Recap Bipartite matchings General matchings Maximum flows Stable matchings Shortest paths Minimum spanning.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
TECH Computer Science Graph Optimization Problems and Greedy Algorithms Greedy Algorithms  // Make the best choice now! Optimization Problems  Minimizing.
Chapter 10: Iterative Improvement Simplex Method The Design and Analysis of Algorithms.
GRAPH Learning Outcomes Students should be able to:
Data Structures Using C++ 2E
Minimal Spanning Trees What is a minimal spanning tree (MST) and how to find one.
Chapter 4 Shortest Path Label-Setting Algorithms Introduction & Assumptions Applications Dijkstra’s Algorithm.
Operations Research Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD4207 University of Palestine.
Lecture 12-2: Introduction to Computer Algorithms beyond Search & Sort.
CSE, IIT KGP Matchings and Factors. CSE, IIT KGP Matchings A matching of size k in a graph G is a set of k pairwise disjoint edges.A matching of size.
1 CS104 : Discrete Structures Chapter V Graph Theory.
EMIS 8374 Optimal Trees updated 25 April slide 1 Minimum Spanning Tree (MST) Input –A (simple) graph G = (V,E) –Edge cost c ij for each edge e 
All Pair Shortest Path IOI/ACM ICPC Training June 2004.
1 1 © 2003 Thomson  /South-Western Slide Slides Prepared by JOHN S. LOUCKS St. Edward’s University.
Minimal Spanning Tree Problems in What is a minimal spanning tree An MST is a tree (set of edges) that connects all nodes in a graph, using.
1 Network Models Transportation Problem (TP) Distributing any commodity from any group of supply centers, called sources, to any group of receiving.
Bipartite Matching. Unweighted Bipartite Matching.
Maximum Flow Chapter 26. Flow Concepts Source vertex s – where material is produced Sink vertex t – where material is consumed For all other vertices.
Graphs A ‘Graph’ is a diagram that shows how things are connected together. It makes no attempt to draw actual paths or routes and scale is generally inconsequential.
Assignments and matchings Chapter 12 Presented by Yorai Geffen.
Chapter 8 Maximum Flows: Additional Topics All-Pairs Minimum Value Cut Problem  Given an undirected network G, find minimum value cut for all.
and 6.855J March 6, 2003 Maximum Flows 2. 2 Network Reliability u Communication Network u What is the maximum number of arc disjoint paths from.
Graph Algorithms Maximum Flow - Best algorithms [Adapted from R.Solis-Oba]
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
15.082J & 6.855J & ESD.78J September 30, 2010 The Label Correcting Algorithm.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
EMIS 8374 The Ford-Fulkerson Algorithm (aka the labeling algorithm) Updated 4 March 2008.
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
Indian Institute of Technology Kharagpur PALLAB DASGUPTA Graph Theory: Matchings and Factors Pallab Dasgupta, Professor, Dept. of Computer Sc. and Engineering,
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
1 Maximum Flows CONTENTS Introduction to Maximum Flows (Section 6.1) Introduction to Minimum Cuts (Section 6.1) Applications of Maximum Flows (Section.
::Network Optimization:: Minimum Spanning Trees and Clustering Taufik Djatna, Dr.Eng. 1.
رياضيات متقطعة لعلوم الحاسب MATH 226. Chapter 10.
1 Graphs Chapters 10.1 and 10.2 University of Maryland Chapters 10.1 and 10.2 Based on slides by Y. Peng University of Maryland.
IOI/ACM ICPC Training 4 June 2005.
Chapter 10 Iterative Improvement
Maximum Flow Chapter 26.
Maximum Flow - Best algorithms
Lectures on Network Flows
Chapter 5. Optimal Matchings
Various Graph Algorithms
3.5 Minimum Cuts in Undirected Graphs
Introduction Basic formulations Applications
Lecture 4 Graph Search.
Lecture 19-Problem Solving 4 Incremental Method
EE5900 Advanced Embedded System For Smart Infrastructure
and 6.855J March 6, 2003 Maximum Flows 2
離散數學 DISCRETE and COMBINATORIAL MATHEMATICS
Text Book: Introduction to algorithms By C L R S
GRAPHS Lecture 17 CS2110 Spring 2018.
The Greedy Approach Young CS 530 Adv. Algo. Greedy.
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
Presentation transcript:

Network Flows Chun-Ta, Yu Graduate Institute Information Management Dept. National Taiwan University

Chapter 12 ASSIGHMENTS AND MATCHINGS

Outline  Introduction  Bipartite Cardinality Matching Problem  Bipartite Weighted Matching Problem  Stable Marriage Problem  Nonbipartite Cardinality Matching Problem

Introduction  Bipartite matching problem 1.The cardinality problem 2.The weighted problem  Stable marriage problem  Nonbipartite matching problem

Bipartite Cardinality Matching Problem  Transform this problem into a maximum flow problem in a simple network –Each arc has a unit capacity and each node has an indegree of at most 1 or an outdegree of at most 1 –Introduce a source node s and a sink node t  Solving this problem at worst-case

Bipartite Cardinality Matching Problem

Bipartite Weighted Matching Problem  Assignment problem  Given a weighted bipartite network

Bipartite Weighted Matching Problem  The assignment problem can be viewed as adaptation of algorithm for the minimum cost flow problem  Four algorithm to solve : 1.Successive Shortest Path Algorithm 2.Hungarian Algorithm 3.Relaxation Algorithm 4.Cost Scaling Algorithm

Successive Shortest Path Algorithm  Discuss in section 9.7  Augment 1 unit flow in every iteration S( n,m,C) n 1 =|N 1 |  Let S( n,m,C) denote the time needed to solve a shortest path problem with nonnegative arc lengths and n 1 =|N 1 | O(n 1 S( n,m,C))  The algorithm would terminate within n 1 iterations and would require O(n 1 S( n,m,C))

Hungarian Algorithm  Discuss in section 9.7, primal-dual algorithm s* t*. s*  With a single supply node s* and a single demand node t*.At every iteration,the primal-dual algorithm computes shortest path distance from s* to all other nodes n 1 O(n 1 S( n,m,C))  The algorithm would terminate within n 1 iterations and would require O(n 1 S( n,m,C))

Relaxation Algorithm  Closely related to the successive shortest path algorithm  Relax the constraint N 2 N 1 thus allowing any node in N 2 to be assigned to more than one node in N 1 O(n 1 S( n,m,C))  Overall running time O(n 1 S( n,m,C))

Stable Marriage Problem  A certain community consists of n men and n women. Each person ranks those of the opposite sex in accordance with his or her preferences for a spouse.  Unstable – if man-woman are not married to each other but prefer each other to their current spouses O(n 2 )  For any set of rankings, we can always find a stable matching in O(n 2 ) time

Stable Marriage Problem n x n  The input to the stable marriage problem consists of two n x n matrices.  Each rank is an integer between 1 and n O(n 2 )  Priority list is a vector of n elements for each person, can be sorted using bucket sort in O(n 2 ) time

Stable marriage algorithm  Propose-and-reject algorithm  Time complexity : –Each iteration each woman receiving a proposal either (1) receives her first proposal (2) rejects some proposal (n-1) –Each woman rejects any man’s proposal at most once, so total rejection times is (n-1) for each woman O(n 2 ) –Total time is O(n 2 )  Man-optimal matching

Nonbipartite Cardinality Matching Problem  Alternating Paths P=i 1 -i 2 - … i k M –We refer to a path P=i 1 -i 2 - … i k in the graph as an alternating path with respect to a matching M if every consecutive pair of arcs in the path contains one matched and one unmatched arc ex :

Nonbipartite Cardinality Matching Problem  Augmenting Paths P –We refer to an odd alternating path P with respect to matching M as an augmenting path if the first and last nodes in the path are unmatched ex : –Interchanging the matched and unmatched arcs on augmenting paths can add one more cardinality

Symmetric Difference S 1 S 2 S 1 ⊕ S 2 S 1 ⊕ S 2 = (S 1 ∪ S 2 )-(S 1 ∩S 2 )  Let S 1 and S 2 be two sets; the symmetric difference of these sets, denoted S 1 ⊕ S 2, is the set S 1 ⊕ S 2 = (S 1 ∪ S 2 )-(S 1 ∩S 2 ) S 1 S 2 S 1 ⊕ S 2 for example, S 1 = {4,5,7,8} and S 2 = {2,4,8,9}, then S 1 ⊕ S 2 ={2,5,7,9}

Property 12.6 MP MM ⊕ P |M| + 1 M ⊕ P P  If M is a matching and P is an augmenting path with respect to M, then M ⊕ P is a matching of cardinality |M| + 1. Moreover, in the matching M ⊕ P, all the matched nodes in M remain matched and two additional nodes, namely the first and last nodes of P, are matched

Property 12.7 MM* G* = (N, M ⊕ M*)  If M and M* are two matchings, their symmetric difference defines the subgraph G* = (N, M ⊕ M*) with the property that every component is one of the six types shown in Figure 12.7

Augmenting Path Theorem pM pp  If a node p is unmatched in a matching M, and this matching contains no augmenting path that starts at node p, then node p is unmatched in some maximum matching.

Bipartite Matching Algorithm M  Start with a feasible matching M (which might be a null matching) and then repeat the following step for every unmatched node pPM M ⊕ Pp Try to identify an augmenting path starting at node p. If we find such a path P, replace M with M ⊕ P; otherwise, delete node p and all the arcs incident to it from the graph

Bipartite Matching Algorithm  Search algorithm

Bipartite Matching Algorithm

 Time complexity : n –The search algorithm execute at most n times i O(|A(i)|)O(m) –For each node i, the search procedure performs one of the following two operations at most once (1) examine-even (2) examine-odd, the former operation require O(|A(i)|) time, about O(m) O(nm) –Total time O(nm)

Unique label property M p  A graph is said to possess a unique label property with respect to a given matching M and a root node p if the search procedure assigns a unique label to every labeled node irrespective of the order in which it examines labeled nodes

 Bipartite network satisfy it; nonbipartite network doesn’t satisfy it

Flower and Blossoms M p  A flower, defined with respect to a matching M and a root node p, is a subgraph with two components : even pw p = w –Stem. A stem is an even length alternating path that starts at the root node p and terminates at some node w. We permit the possibility that p = w, in which case we say that the stem is empty odd w w –Blossom. A blossom is an odd length alternating cycle that starts and terminates at the terminal node w of a stem and has no other node in common with the stem. We refer to node w as the base of the blossom

Flower and Blossoms

Property l+1l l ≧ 0 a) A stem spans 2l+1 nodes and contains l matched arcs for some integer l ≧ 0 2k+1k k ≧ 1. b) A blossom spans 2k+1 nodes and contains k matched arcs for some integer k ≧ 1. The matched arcs match all nodes of the blossom except its base c) The base of blossom is an even node

Property i  Every node i in the blossom (except its base) is reachable from the root (or from the base of the blossom) through two distinct alternating paths. One has even length and the other has odd length

Contracting a Blossom A(b) = A(i 1 ) ∪ A(i 2 ) ∪ … ∪ A(j k ) 1. Introduce a new node b (pseudonode) and define its adjacency list A(b) = A(i 1 ) ∪ A(i 2 ) ∪ … ∪ A(j k ) 2. Update the adjacency list of every node A(j)=A(j) ∪ {b} by executing A(j)=A(j) ∪ {b} 3. To be able to recover, set contracted node to “inactive” mode

Nonbipartite matching algorithm

Nonbipartite matching algorithm-- Find a augmenting path

Complexity of nonbipartite matching algorithm  Lemma n/2 –During an execution of the search procedure, the algorithm performs at most n/2 contractions n/2 3n/2  Since each contraction adds at most one element to any adjacency list (the pseudonode), and since the algorithm performs at most n/2 contractions, no adjacency list will ever contain more than 3n/2 i |A c (i)| ≦ 3n/2, O(n 2 )  Each search procedure performs one of the following operation at most once: (1)it discovers that node i is inactive (2)examine-odd(3)examine-even, (3) require |A c (i)| ≦ 3n/2, so running time is O(n 2 ) O(n 3 )  Total time complexity O(n 3 )

Chapter 13 MINIMUM SPANNING TREES

Outline  Introduction  Optimality Condition  Kruskal’s Algorithm  Prim’s Algorithm  Sollin’s Algorithm

Introduction

Optimality Condition  Cut Optimality Conditions T* –A Spanning tree T* is a minimum spanning tree if and only if it satisfies the following cut optimality condition: For every tree arc, c ij ≦ c kl (k, l) (i, j)T* c ij ≦ c kl for every arc (k, l) contained in the cut formed by deleting arc (i, j) from T*

Optimality Condition  Path Optimality Conditions (k, l) Gc ij ≦ c kl (i, j) T*kl –A spanning tree T* is a minimum spanning tree if and only if it satisfies the following path optimality conditions: For every nontree arc (k, l) of G, c ij ≦ c kl for every arc (i, j) contained in the path in T* connecting nodes k and l

Kruskal’s Algorithm O(mn )  Time Complexity O(mn )

Prim’s Algorithm O(m log n)  Time Complexity O(m log n)

Sollin’s Algorithm O(m log n)  Time Complexity O(m log n)

Summary of minimum spanning tree algorithm

Matroids and the Greedy Algorithm I  Independent : a subset I of objects do not form a cycle in the network (E, ζ) ζ  Subset System (E, ζ) : a finite set of objects E and nonempty collection ζ of subsets of these objects I p I p+1 pp+1 I p ∪ {e}  Matroid : a subset system satisfies the growth property that if I p and I p+1 are independent sets containing p and p+1 elements, we always can find an element, satisfying the property that I p ∪ {e} is an independent set

Matroids and the Greedy Algorithm  Maximal independent set : an independent set I satisfying the property that we cannot add any other element e to I and produce another independent set  Greedy algorithm :

Thank You!