graph algorithms
play

Graph Algorithms Algorithm Theory WS 2012/13 Fabian Kuhn Graphs - PowerPoint PPT Presentation

Chapter 5 Graph Algorithms Algorithm Theory WS 2012/13 Fabian Kuhn Graphs Extremely important concept in computer science Graph , : node (or vertex) set : edge set Simple graph: no self


  1. Ford ‐ Fulkerson Gives Optimal Solution Lemma: If � is an � ‐ � flow such that there is no augmenting path in � � , then there is an � ‐ � cut �� ∗ , � ∗ � in � for which � � � � ∗ , � ∗ . Proof: • Define � ∗ : set of nodes that can be reached from � on a path with positive residual capacities in � � : • For � ∗ � � ∖ � ∗ , �� ∗ , � ∗ � is an � ‐ � cut – By definition � ∈ � ∗ and � ∉ � ∗ Algorithm Theory, WS 2012/13 Fabian Kuhn 29

  2. Ford ‐ Fulkerson Gives Optimal Solution Lemma: If � is an � ‐ � flow such that there is no augmenting path in � � , then there is an � ‐ � cut �� ∗ , � ∗ � in � for which � � � � ∗ , � ∗ . Proof: Algorithm Theory, WS 2012/13 Fabian Kuhn 30

  3. Ford ‐ Fulkerson Gives Optimal Solution Lemma: If � is an � ‐ � flow such that there is no augmenting path in � � , then there is an � ‐ � cut �� ∗ , � ∗ � in � for which � � � � ∗ , � ∗ . Proof: Algorithm Theory, WS 2012/13 Fabian Kuhn 31

  4. Ford ‐ Fulkerson Gives Optimal Solution Theorem: The flow returned by the Ford ‐ Fulkerson algorithm is a maximum flow. Proof: Algorithm Theory, WS 2012/13 Fabian Kuhn 32

  5. Min ‐ Cut Algorithm Ford ‐ Fulkerson also gives a min ‐ cut algorithm: Theorem: Given a flow � of maximum value, we can compute an � ‐ � cut of minimum capacity in ���� time. Proof: Algorithm Theory, WS 2012/13 Fabian Kuhn 33

  6. Max ‐ Flow Min ‐ Cut Theorem Theorem: (Max ‐ Flow Min ‐ Cut Theorem) In every flow network, the maximum value of an � ‐ � flow is equal to the minimum capacity of an � ‐ � cut. Proof: Algorithm Theory, WS 2012/13 Fabian Kuhn 34

  7. Integer Capacities Theorem: (Integer ‐ Valued Flows) If all capacities in the flow network are integers, then there is a maximum flow � for which the flow � � of every edge � is an integer. Proof: Algorithm Theory, WS 2012/13 Fabian Kuhn 35

  8. Non ‐ Integer Capacities What if capacities are not integers? • rational capacities: – can be turned into integers by multiplying them with large enough integer – algorithm still works correctly • real (non ‐ rational) capacities: – not clear whether the algorithm always terminates • even for integer capacities, time can linearly depend on the value of the maximum flow Algorithm Theory, WS 2012/13 Fabian Kuhn 36

  9. Slow Execution 1000 1000 � � � � � 1 � � � � � 1000 1000 • Number of iterations: 2000 (value of max. flow) Algorithm Theory, WS 2012/13 Fabian Kuhn 37

  10. Improved Algorithm Idea: Find the best augmenting path in each step • best: path � with maximum bottleneck��, �� • Best path might be rather expensive to find  find almost best path • Scaling parameter � : (initially, Δ � "max � � rounded down to next power of 2" ) • As long as there is an augmenting path that improves the flow by at least Δ , augment using such a path • If there is no such path: Δ ≔ � � ⁄ Algorithm Theory, WS 2012/13 Fabian Kuhn 38

  11. Scaling Parameter Analysis Lemma: If all capacities are integers, number of different scaling parameters used is � 1 � �log � �� . • � ‐ scaling phase: Time during which scaling parameter is Δ Algorithm Theory, WS 2012/13 Fabian Kuhn 39

  12. Length of a Scaling Phase Lemma: If � is the flow at the end of the Δ ‐ scaling phase, the maximum flow in the network has value at most � � �Δ . Algorithm Theory, WS 2012/13 Fabian Kuhn 40

  13. Length of a Scaling Phase Lemma: The number of augmentation in each scaling phase is at most 2� . Algorithm Theory, WS 2012/13 Fabian Kuhn 41

  14. Running Time: Scaling Max Flow Alg. Theorem: The number of augmentations of the algorithm with scaling parameter and integer capacities is at most ��� log �� . The algorithm can be implemented in time � � � log � . Algorithm Theory, WS 2012/13 Fabian Kuhn 42

  15. Strongly Polynomial Algorithm • Time of regular Ford ‐ Fulkerson algorithm with integer capacities: ����� • Time of algorithm with scaling parameter: � � � log � • ��log �� is polynomial in the size of the input, but not in � • Can we get an algorithm that runs in time polynomial in � ? • Always picking a shortest augmenting path leads to running time ��� � �� Algorithm Theory, WS 2012/13 Fabian Kuhn 43

  16. Preflow ‐ Push Max ‐ Flow Algorithm Definition: An � ‐ � preflow is a function �: E → � �� such that • For each edge � ∈ � : � � � � � • For each node � ∈ � ∖ ��� : � � � � � ���� � ���� � � ��� �� � Excess of node � : � � � � � � � � � ���� � ���� � � ��� �� � • A preflow � with excess � � � � 0 for all � � �, � is a flow with value � � � � � � �� � ��� . Algorithm Theory, WS 2012/13 Fabian Kuhn 44

  17. Preflows and Labelings Height function �: � → � � • Assigns an integer height to each node � ∈ � Source and Sink Conditions: • � � � � and � � � 0 Steepness Condition: • For all edges � � ��, �� with residual capacity � 0 (residual graph � � for a preflow � defined as before for flows) � � � � � � 1 • A preflow � and a labeling � are called compatible if source, sink, and steepness conditions are satisfied Algorithm Theory, WS 2012/13 Fabian Kuhn 45

  18. Compatible Labeling height Arrows: edges of � � with positive residual capacity 8 7 6 5 4 3 2 1 Algorithm Theory, WS 2012/13 Fabian Kuhn 46

  19. Preflows with Compatible Labelings Lemma: If a preflow � is compatible with a labeling � , then there is no � ‐ � path in � � with only positive residual capacities. Algorithm Theory, WS 2012/13 Fabian Kuhn 47

  20. Flows with Compatible Labelings Lemma: If � ‐ � flow � is compatible with a labeling � , then � is a flow of maximum value. Algorithm Theory, WS 2012/13 Fabian Kuhn 48

  21. Turning a Preflow into a Flow Algorithm Idea: • Start with a preflow � and a compatible labeling • Extend preflow � while keeping a compatible labeling • As soon as � is a flow (nodes � � �, � have excess � � � � 0 ), � is a maximum flow Initialization: • Labeling � : � � � � , � � � 0 for all � � � • Preflow � : – Edges � � ��, �� of � � out of � need residual capacity 0 : � � � � � – Preflow on other edges � does not matter: � � � 0 Algorithm Theory, WS 2012/13 Fabian Kuhn 49

  22. Initialization Initial labeling � : � � � � , � � � 0 for � � � Initial preflow � : edge � out of � : � � � � � , other edges � : � � � 0 Claim: Initial labeling � and preflow � are compatible. Algorithm Theory, WS 2012/13 Fabian Kuhn 50

  23. Push Consider some node � with excess � � � � 0 : • Assume � has a neighbor � in the residual graph � � such that the edge � � ��, �� has positive residual capacity and � � � ���� : push flow from � to � • If � is a forward edge: increase ���� by min � � � , � � � ���� • If � is a backward edge: decrease � � by min � � � , ���� Algorithm Theory, WS 2012/13 Fabian Kuhn 51

  24. Relabel Consider some node � with excess � � � � 0 : • Assume that it is not possible to push flow to a neighbor in � � : For all edges � � ��, �� in � � with positive residual capacity, we have � � � � � relabel � : � � ≔ � � � � Algorithm Theory, WS 2012/13 Fabian Kuhn 52

  25. Preflow ‐ Push Algorithm • As long as there is a node � with excess � � � � 0 , if possible do a push operation from � to a neighbor, otherwise relabel � Lemma: Throughout the Preflow ‐ Push Algorithm: i. Labels are non ‐ negative integers If capacities are integers, � is an integer preflow ii. iii. The preflow � and the labeling � are compatible If the algorithm terminates, � is a maximum flow. Algorithm Theory, WS 2012/13 Fabian Kuhn 53

  26. Properties of Preflows Lemma: If � is a preflow and node � has excess � � � � 0 , then there is a path with positive residual capacities in � � from � to � . Algorithm Theory, WS 2012/13 Fabian Kuhn 54

  27. Heights Lemma: During the algorithm, all nodes � have � � � 2� � 1 . Algorithm Theory, WS 2012/13 Fabian Kuhn 55

  28. Number of Relabelings Lemma: During the algorithm, each node is relabeled at most 2� � 1 times. • Hence: total number or relabeling operations � 2� � Algorithm Theory, WS 2012/13 Fabian Kuhn 56

  29. Number of Saturating Push Operations • A push operation on �, � is called saturating if: – � � ��, �� is a forward edge and after the push, � �, � � � � – � � ��, �� is a backward edge and after the push, � �, � � 0 Lemma: The number of saturating push operations is at most 2�� . Algorithm Theory, WS 2012/13 Fabian Kuhn 57

  30. Number of Non ‐ Saturating Push Ops. Lemma: There are � 2� � � non ‐ saturating push operations. Proof: • Potential function: Φ �, � ≔ � ���� �:� � � �� • At all times, � �, � � � • Non ‐ saturating push on ��, �� : – Before push: � � � � 0 , after push: � � � � 0 – Push might increase � � ��� from 0 to � 0 – � � � � � � 1 push decreases ���, �� by at least �  • Relabel: increases ���, �� by � • Saturating push on ��, �� : � � ��� might be positive afterwards  � �, � increases by at most � � � �� � � Algorithm Theory, WS 2012/13 Fabian Kuhn 58

  31. Number of Non ‐ Saturating Push Ops. Lemma: There are � 2� � � non ‐ saturating push operations. Proof: • Potential function Φ �, � � 0 • Non ‐ saturating push decreases Φ��, �� by 1 • Relabel increases Φ��, �� by 1 • Saturating push increase Φ �, � by � 2� � 1 Algorithm Theory, WS 2012/13 Fabian Kuhn 59

  32. Preflow ‐ Push Algorithm Theorem: The preflow ‐ push algorithm computes a maximum flow after at most ���� � � push and relabel operations. Algorithm Theory, WS 2012/13 Fabian Kuhn 60

  33. Choosing a Maximum Height Node Lemma: If we always choose a node � with � � � � 0 at maximum height, there are at most ��� � � non ‐ saturating push operations. Proof: New potential function: � ≔ �:� � � �� ���� max Algorithm Theory, WS 2012/13 Fabian Kuhn 61

  34. Choosing a Maximum Height Node Lemma: If we always choose a node � with � � � � 0 at maximum height, there are at most ��� � � non ‐ saturating push operations. Proof: New potential function: � ≔ �:� � � �� ���� max Algorithm Theory, WS 2012/13 Fabian Kuhn 62

  35. Improved Preflow ‐ Push Algorithm Theorem: If we always use a maximum height node with positive excess, the preflow ‐ push algorithm computes a maximum flow after at most ��� � � push and relabel operations. Theorem: The preflow ‐ push algorithm that always chooses a maximum height node with positive excess can be implemented in time � � � . Proof: see exercises Algorithm Theory, WS 2012/13 Fabian Kuhn 63

  36. Maximum Flow Applications • Maximum flow has many applications • Reducing a problem to a max flow problem can even be seen as an important algorithmic technique • Examples: – related network flow problems – computation of small cuts – computation of matchings – computing disjoint paths – scheduling problems – assignment problems with some side constraints – … Algorithm Theory, WS 2012/13 Fabian Kuhn 64

  37. Undirected Edges and Vertex Capacities Undirected Edges: • Undirected edge ��, �� : add edges �, � and ��, �� to network Vertex Capacities: • Not only edge, but also (or only) nodes have capacities • Capacity � � of node � ∉ ��, �� : � �� � � � ��� � � � � • Replace node � by edge � � � �� �� , � ��� � : � �� �� ��� ��� Algorithm Theory, WS 2012/13 Fabian Kuhn 65

  38. Minimum ‐ Cut Given: undirected graph � � ��, �� , nodes �, � ∈ � � ‐ � cut: Partition ��, �� of � such that � ∈ � , � ∈ � Size of cut ��, �� : number of edges crossing the cut Objective: find � ‐ � cut of minimum size Algorithm Theory, WS 2012/13 Fabian Kuhn 66

  39. Edge Connectivity Definition: A graph � � �, � is � ‐ edge connected for an integer � � 1 if the graph � � � ��, � ∖ �� is connected for every edge set � ⊆ �, � � � � 1. Goal: Compute edge connectivity ���� of � (and edge set � of size ���� that divides � into � 2 parts) • minimum set � is a minimum � ‐ � cut for some �, � ∈ � – Actually for all �, � in different components of � � � ��, � ∖ �� • Possible algorithm: fix � and find min � ‐ � cut for all � � � Algorithm Theory, WS 2012/13 Fabian Kuhn 67

  40. Minimum ‐ Vertex ‐ Cut Given: undirected graph � � ��, �� , nodes �, � ∈ � � ‐ � vertex cut: Set � ⊂ � such that �, � ∉ � and � and � are in different components of the sub ‐ graph ��� ∖ �� induced by � ∖ � Size of vertex cut: |�| Objective: find � ‐ � vertex ‐ cut of minimum size • Replace undirected edge ��, �� by ��, �� and ��, �� • Compute max � ‐ � flow for edge capacities ∞ and node capacities � � � 1 for � � �, � • Replace each node � by � �� and � ��� : • Min edge cut corresponds to min vertex cut in � Algorithm Theory, WS 2012/13 Fabian Kuhn 68

  41. Vertex Connectivity Definition: A graph � � �, � is � ‐ vertex connected for an integer � � 1 if the sub ‐ graph ��� ∖ �� induced by � ∖ � is connected for every edge set � ⊆ �, � � � � 1. Goal: Compute vertex connectivity ���� of � (and node set � of size ���� that divides � into � 2 parts) • Compute minimum � ‐ � vertex cut for fixed � and all � � � Algorithm Theory, WS 2012/13 Fabian Kuhn 69

  42. Edge ‐ Disjoint Paths Given: Graph � � ��, �� with nodes �, � ∈ � Goal: Find as many edge ‐ disjoint � ‐ � paths as possible Solution: • Find max � ‐ � flow in � with edge capacities � � � 1 for all � ∈ � Flow � induces � edge ‐ disjoint paths: • Integral capacities  can compute integral max flow � • Get � edge ‐ disjoint paths by greedily picking them • Correctness follows from flow conservation � �� � � � ��� ��� Algorithm Theory, WS 2012/13 Fabian Kuhn 70

  43. Vertex ‐ Disjoint Paths Given: Graph � � ��, �� with nodes �, � ∈ � Goal: Find as many internally vertex ‐ disjoint � ‐ � paths as possible Solution: • Find max � ‐ � flow in � with node capacities � � � 1 for all � ∈ � Flow � induces � vertex ‐ disjoint paths: • Integral capacities  can compute integral max flow � • Get � vertex ‐ disjoint paths by greedily picking them • Correctness follows from flow conservation � �� � � � ��� ��� Algorithm Theory, WS 2012/13 Fabian Kuhn 71

  44. Menger’s Theorem Theorem: (edge version) For every graph � � ��, �� with nodes �, � ∈ � , the size of the minimum � ‐ � (edge) cut equals the maximum number of pairwise edge ‐ disjoint paths from � to � . Theorem: (node version) For every graph � � ��, �� with nodes �, � ∈ � , the size of the minimum � ‐ � vertex cut equals the maximum number of pairwise internally vertex ‐ disjoint paths from � to � • Both versions can be seen as a special case of the max flow min cut theorem Algorithm Theory, WS 2012/13 Fabian Kuhn 72

  45. Baseball Elimination Against = � �� Team Wins Losses To Play � � � ℓ � � � NY Balt. T. Bay Tor. Bost. New York 81 70 11 ‐ 2 4 2 3 Baltimore 79 77 6 2 ‐ 2 1 1 Tampa Bay 78 76 8 4 2 ‐ 1 1 Toronto 76 80 6 2 1 1 ‐ 2 Boston 72 83 7 3 1 1 2 ‐ • Only wins/losses possible (no ties), winner: team with most wins • Which teams can still win (as least as many wins as top team)? • Boston is eliminated (cannot win): – Boston can get at most 79 wins, New York already has 81 wins • If for some �, � : � � � � � � � �  team � is eliminated • Sufficient condition, but not a necessary one! Algorithm Theory, WS 2012/13 Fabian Kuhn 73

  46. Baseball Elimination Against = � �� Team Wins Losses To Play � � � ℓ � � � NY Balt. T. Bay Tor. Bost. New York 81 70 11 ‐ 2 4 2 3 Baltimore 79 77 6 2 ‐ 2 1 1 Tampa Bay 78 76 8 4 2 ‐ 1 1 Toronto 76 80 6 2 1 1 ‐ 2 Boston 72 83 7 3 1 1 2 ‐ • Can Toronto still finish first? • Toronto can get 82 � 81 wins, but: NY and Tampa have to play 4 more times against each other  if NY wins one, it gets 82 wins, otherwise, Tampa has 82 wins • Hence: Toronto cannot finish first • How about the others? How can we solve this in general? Algorithm Theory, WS 2012/13 Fabian Kuhn 74

  47. Max Flow Formulation • Can team 3 finish with most wins? 1 2 1 ‐ 2 1 1 ‐ 4 1 4 2 1 5 1 ‐ 5 2 4 2 ‐ 4 4 2 5 2 ‐ 5 5 4 5 4 ‐ 5 Remaining number team Number of wins team � can of games between have to not beat team � nodes game the 2 teams nodes • Team 3 can finish first iff all source ‐ game edges are saturated Algorithm Theory, WS 2012/13 Fabian Kuhn 75

  48. Reason for Elimination AL East: Aug 30, 1996 Against = � �� Team Wins Losses To Play � � � ℓ � � � NY Balt. Bost. Tor. Detr. New York 75 59 28 ‐ 3 8 7 3 Baltimore 71 63 28 3 ‐ 2 7 4 Boston 69 66 27 8 2 ‐ 0 0 Toronto 63 72 27 7 7 0 ‐ 0 Detroit 49 86 27 3 4 0 0 ‐ • Detroit could finish with 49 � 27 � 76 wins • Consider � � �NY, Bal, Bos, Tor� – Have together already won � � � 278 games – Must together win at least � � � 27 more games ������ • On average, teams in � win � 76.25 games � Algorithm Theory, WS 2012/13 Fabian Kuhn 76

  49. Reason for Elimination Certificate of elimination: � ⊆ �, � � ≔ � � � , � � ≔ � � �,� �∈� �,�∈� #wins of #remaining games nodes in � among nodes in � Team � ∈ � is eliminated by � if � � � ���� � � � � � � . |�| Algorithm Theory, WS 2012/13 Fabian Kuhn 77

  50. Reason for Elimination Theorem: Team � is eliminated if and only if there exists a subset � ⊆ � of the teams � such that � is eliminated by � . Proof Idea: • Minimum cut gives a certificate… • If � is eliminated, max flow solution does not saturate all outgoing edges of the source. • Team nodes of unsaturated source ‐ game edges are saturated • Source side of min cut contains all teams of saturated team ‐ dest. edges of unsaturated source ‐ game edges • Set of team nodes in source ‐ side of min cut give a certificate � Algorithm Theory, WS 2012/13 Fabian Kuhn 78

  51. Circulations with Demands Given: Directed network with positive edge capacities Sources & Sinks: Instead of one source and one destination, several sources that generate flow and several sinks that absorb flow. Supply & Demand: sources have supply values, sinks demand values Goal: Compute a flow such that source supplies and sink demands are exactly satisfied • The circulation problem is a feasibility rather than a maximization problem Algorithm Theory, WS 2012/13 Fabian Kuhn 79

  52. Circulations with Demands: Formally Given: Directed network � � �, � with • Edge capacities � � � 0 for all � ∈ � • Node demands � � ∈ � for all � ∈ � – � � � 0 : node needs flow and therefore is a sink – � � � 0 : node has a supply of �� � and is therefore a source – � � � 0 : node is neither a source nor a sink Flow: Function �: � → � �� satisfying • Capacity Conditions : ∀� ∈ �: 0 � � � � � � • Demand Conditions : ∀� ∈ �: � �� � � � ��� � � � � Objective: Does a flow � satisfying all conditions exist? If yes, find such a flow � . Algorithm Theory, WS 2012/13 Fabian Kuhn 80

  53. Example ‐ 3 ‐ 3 3 3 1 2 2 ‐ 3 ‐ 3 2 2 2 2 2 2 4 Algorithm Theory, WS 2012/13 Fabian Kuhn 81

  54. Condition on Demands Claim: If there exists a feasible circulation with demands � � for � ∈ � , then � � � � 0. �∈� Proof: � �� � � � ��� � • ∑ � � � ∑ � � • ���� of each edge � appears twice in the above sum with different signs  overall sum is 0 Total supply = total demand: Define � ≔ � � � � � �� � �:� � �� �:� � �� Algorithm Theory, WS 2012/13 Fabian Kuhn 82

  55. Reduction to Maximum Flow • Add “super ‐ source” � ∗ and “super ‐ sink” � ∗ to network 0 0 1 � ‐ 3 ‐ 3 � 0 � � ∗ ∗ ‐ 1 ‐ 1 4 � 2 � 0 � ‐ 6 ‐ 6 0 3 � ∗ supplies � ∗ siphons 0 sources flow out with flow of sinks Algorithm Theory, WS 2012/13 Fabian Kuhn 83

  56. Example 3 ∗ ‐ 3 ‐ 3 3 3 3 3 3 1 2 2 ‐ 3 ‐ 3 2 2 2 2 2 2 2 2 4 ∗ 4 4 Algorithm Theory, WS 2012/13 Fabian Kuhn 84

  57. Formally… Reduction: Get graph � � from graph as follows • Node set of � � is � ∪ � ∗ , � ∗ • Edge set is � and edges – �� ∗ , �� for all � with � � � 0 , capacity of edge is �� � – ��, � ∗ � for all � with � � � 0 , capacity of edge is � � Observations: • Capacity of min � ∗ ‐ � ∗ cut is at least � (e.g., the cut � ∗ , � ∪ �� ∗ � • A feasible circulation on � can be turned into a feasible flow of value � of �′ by saturating all �� ∗ , �� and ��, � ∗ � edges. • Any flow of �′ of value � induces a feasible circulation on � � ∗ , � and �, � ∗ edges are saturated – – By removing these edges, we get exactly the demand constraints Algorithm Theory, WS 2012/13 Fabian Kuhn 85

  58. Circulation with Demands Theorem: There is a feasible circulation with demands � � , � ∈ � on graph � if and only if there is a flow of value � on �′ . • If all capacities and demands are integers, there is an integer circulation The max flow min cut theorem also implies the following: Theorem: The graph � has a feasible circulation with demands � � , � ∈ � if and only if for all cuts ��, �� , � � � � ���, �� . �∈� Algorithm Theory, WS 2012/13 Fabian Kuhn 86

  59. Circulation: Demands and Lower Bounds Given: Directed network � � �, � with • Edge capacities � � � 0 and lower bounds � � ℓ � � � � for � ∈ � • Node demands � � ∈ � for all � ∈ � – � � � 0 : node needs flow and therefore is a sink – � � � 0 : node has a supply of �� � and is therefore a source – � � � 0 : node is neither a source nor a sink Flow: Function �: � → � �� satisfying • Capacity Conditions : ∀� ∈ �: ℓ � � � � � � � • Demand Conditions : ∀� ∈ �: � �� � � � ��� � � � � Objective: Does a flow � satisfying all conditions exist? If yes, find such a flow � . Algorithm Theory, WS 2012/13 Fabian Kuhn 87

  60. Solution Idea • Define initial circulation � � � � ℓ � Satisfies capacity constraints: ∀� ∈ �: ℓ � � � � � � � � • Define �� � � � ��� � � � � ≔ � � ℓ � � � ℓ � � � � ���� � � ��� �� � • If � � � 0 , demand condition is satisfied at � by � � , otherwise, we need to superimpose another circulation � � such that � ≔ � �� � � � ��� � � � � � � � � � � � � ≔ � � � ℓ � • Remaining capacity of edge � : � � � , new • We get a circulation problem with new demands � � � , and no lower bounds capacities � � Algorithm Theory, WS 2012/13 Fabian Kuhn 88

  61. Eliminating a Lower Bound: Example Lower bound of 2 ‐ 3 ‐ 3 ‐ 1 ‐ 1 3 1 3 3 2 2 ‐ 3 ‐ 3 2 ‐ 5 ‐ 5 2 2 2 2 2 4 4 Algorithm Theory, WS 2012/13 Fabian Kuhn 89

  62. Reduce to Problem Without Lower Bounds Graph � � ��, �� : • Capacity: For each edge � ∈ � : ℓ � � � � � � � • Demand: For each node � ∈ � : � �� � � � ��� � � � � Model lower bounds with supplies & demands: � � Flow: ℓ � Create Network �′ (without lower bounds): � � � � � ℓ � • For each edge � ∈ � : � � � � � � � � � • For each node � ∈ � : � � Algorithm Theory, WS 2012/13 Fabian Kuhn 90

  63. Circulation: Demands and Lower Bounds Theorem: There is a feasible circulation in � (with lower bounds) if and only if there is feasible circulation in �′ (without lower bounds). • Given circulation �′ in �′ , � � � � � � � ℓ � is circulation in � – The capacity constraints are satisfied because � � � � � � � ℓ � – Demand conditions: � �� � � � ��� � � ℓ � � � � ��� � ℓ � � � � ��� � � � ���� � � ��� �� � � � � � � � � � � � � � • Given circulation �′ in �′ , � � � � � � � ℓ � is circulation in � – The capacity constraints are satisfied because � � � � � � � ℓ � – Demand conditions: �′ �� � � � ���� � � � � � � ℓ � � � � � � ℓ � � ���� � � ��� �� � � � � � � � Algorithm Theory, WS 2012/13 Fabian Kuhn 91

  64. Integrality Theorem: Consider a circulation problem with integral capacities, flow lower bounds, and node demands. If the problem is feasible, then it also has an integral solution. Proof: • Graph �′ has only integral capacities and demands • Thus, the flow network used in the reduction to solve circulation with demands and no lower bounds has only integral capacities • The theorem now follows because a max flow problem with integral capacities also has an optimal integral solution • It also follows that with the max flow algorithms we studied, we get an integral feasible circulation solution. Algorithm Theory, WS 2012/13 Fabian Kuhn 92

  65. Matrix Rounding • Given: � � � matrix � � �� �,� � of real numbers • row � sum: � � � ∑ � �,� � � ∑ � �,� , column � sum: � � � • Goal: Round each � �,� , as well as � � and � � up or down to the next integer so that the sum of rounded elements in each row (column) equals the rounded row (column) sum • Original application: publishing census data Example: 3.14 6.80 7.30 17.24 3 7 7 17 9.60 2.40 0.70 12.70 10 2 1 13 3.60 1.20 6.50 11.30 3 1 7 11 16.34 10.40 14.50 16 10 15 original data possible rounding Algorithm Theory, WS 2012/13 Fabian Kuhn 93

  66. Matrix Rounding Theorem: For any matrix, there exists a feasible rounding. Remark: Just rounding to the nearest integer doesn’t work 0.35 0.35 0.35 1.05 0.55 0.55 0.55 1.65 0.90 0.90 0.90 original data 0 0 0 0 0 0 1 1 1 1 1 3 1 1 0 2 1 1 1 1 1 1 feasible rounding rounding to nearest integer Algorithm Theory, WS 2012/13 Fabian Kuhn 94

  67. Reduction to Circulation 3.14 6.80 7.30 17.24 Matrix elements and row/column sums 9.60 2.40 0.70 12.70 give a feasible circulation that satisfies all lower bound, capacity, and demand 3.60 1.20 6.50 11.30 constraints 16.34 10.40 14.50 rows: columns: 3,4 � � � � � � � � 12,13 2,3 10,11 � � � � � � � � � � � � � � � � ∞ all demands � � � 0 Algorithm Theory, WS 2012/13 Fabian Kuhn 95

  68. Matrix Rounding Theorem: For any matrix, there exists a feasible rounding. Proof: • The matrix entries � �,� and the row and column sums � � and � � give a feasible circulation for the constructed network • Every feasible circulation gives matrix entries with corresponding row and column sums (follows from demand constraints) • Because all demands, capacities, and flow lower bounds are integral, there is an integral solution to the circulation problem  gives a feasible rounding! Algorithm Theory, WS 2012/13 Fabian Kuhn 96

  69. Matching Algorithm Theory, WS 2012/13 Fabian Kuhn 97

  70. Gifts ‐ Children Graph • Which child likes which gift can be represented by a graph Algorithm Theory, WS 2012/13 Fabian Kuhn 98

  71. Matching Matching: Set of pairwise non ‐ incident edges Maximal Matching: A matching s.t. no more edges can be added Maximum Matching: A matching of maximum possible size Perfect Matching: Matching of size � � ⁄ (every node is matched) Algorithm Theory, WS 2012/13 Fabian Kuhn 99

  72. Bipartite Graph Definition: A graph � � �, � is called bipartite iff its node set ⋅ can be partitioned into two parts � � � � ∪ � � such that for each edge u, v ∈ � , �, � ∩ � � � 1. • Thus, edges are only between the two parts � � Algorithm Theory, WS 2012/13 Fabian Kuhn 100

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend