1 / 50

Network Flows

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

Télécharger la présentation

Network Flows

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.


Presentation Transcript

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


  3. Outline • Introduction • Bipartite Cardinality Matching Problem • Bipartite Weighted Matching Problem • Stable Marriage Problem • Nonbipartite Cardinality Matching Problem

  4. Introduction • Bipartite matching problem • The cardinality problem • The weighted problem • Stable marriage problem • Nonbipartite matching problem

  5. 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

  6. Bipartite Cardinality Matching Problem

  7. Bipartite Weighted Matching Problem • Assignment problem • Given a weighted bipartite network

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

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

  10. Hungarian Algorithm • Discuss in section 9.7, primal-dual algorithm • 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 • The algorithm would terminate within n1 iterations and would require O(n1S( n ,m ,C))

  11. Relaxation Algorithm • Closely related to the successive shortest path algorithm • Relax the constraint thus allowing any node in N2 to be assigned to more than one node in N1 • Overall running time O(n1S( n ,m ,C))

  12. 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 • For any set of rankings, we can always find a stable matching in O(n2) time

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

  14. 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 • Each woman rejects any man’s proposal at most once, so total rejection times is (n-1) for each woman • Total time is O(n2) • Man-optimal matching

  15. Nonbipartite Cardinality Matching Problem • Alternating Paths • We refer to a path P=i1-i2-…ik 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:1-2-4-3-5

  16. Nonbipartite Cardinality Matching Problem • Augmenting Paths • 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:1-2-4-3-5-6 • Interchanging the matched and unmatched arcs on augmenting paths can add one more cardinality

  17. Symmetric Difference • Let S1and S2 be two sets; the symmetric difference of these sets, denoted S1⊕S2, is the set S1⊕S2= (S1∪S2)-(S1∩S2) for example, S1 = {4,5,7,8} and S2 = {2,4,8,9} , then S1⊕S2 ={2,5,7,9}

  18. Property 12.6 • 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

  19. Property 12.7 • 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

  20. Augmenting Path Theorem • 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.

  21. Bipartite Matching Algorithm • Start with a feasible matching M (which might be a null matching) and then repeat the following step for every unmatched node 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

  22. Bipartite Matching Algorithm • Search algorithm

  23. Bipartite Matching Algorithm

  24. Bipartite Matching Algorithm • Time complexity: • The search algorithm execute at most n times • 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) • Total time O(nm)

  25. Unique label property • 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

  26. Bipartite network satisfy it; nonbipartite network doesn’t satisfy it

  27. Flower and Blossoms • A flower, defined with respect to a matching M and a root node p, is a subgraph with two components: • Stem. A stem is aneven 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 • 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

  28. Flower and Blossoms

  29. Property 12.9 • A stem spans 2l+1 nodes and contains l matched arcs for some integer l≧0 • 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 • The base of blossom is an even node

  30. Property 12.10 • 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

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

  32. Nonbipartite matching algorithm

  33. Nonbipartite matching algorithm-- Find a augmenting path

  34. Complexity of nonbipartite matching algorithm • Lemma 12.13 • During an execution of the search procedure, the algorithm performs at most n/2 contractions • 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 • 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 |Ac(i)|≦3n/2, so running time is O(n2) • Total time complexity O(n3)


  36. Outline • Introduction • Optimality Condition • Kruskal’s Algorithm • Prim’s Algorithm • Sollin’s Algorithm

  37. Introduction

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

  39. Optimality Condition • Path Optimality Conditions • 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, cij≦ckl for every arc (i, j) contained in the path in T* connecting nodes k and l

  40. Kruskal’s Algorithm • Time Complexity O(mn )

  41. Prim’s Algorithm • Time Complexity O(m log n)

  42. Sollin’s Algorithm • Time Complexity O(m log n)

  43. Summary of minimum spanning tree algorithm

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

  45. 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:

  46. Thank You!

More Related