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

Size: px
Start display at page:

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

Transcription

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

2 Graphs Extremely important concept in computer science Graph, : node (or vertex) set : edge set Simple graph: no self loops, no multiple edges Undirected graph: we often think of edges as sets of size 2 (e.g.,, ) Directed graph: edges are sometimes also called arcs Weighted graph: (positive) weight on edges (or nodes) (simple) path: sequence,, of nodes such that, for all 0,, 1 Many real world problems can be formulated as optimization problems on graphs Algorithm Theory, WS 2012/13 Fabian Kuhn 2

3 Graph Optimization: Examples Minimum spanning tree (MST): Compute min. weight spanning tree of a weighted undir. Graph Shortest paths: Compute (length) of shortest paths (single source, all pairs, ) Traveling salesperson (TSP): Compute shortest TSP path/tour in weighted graph Vertex coloring: Color the nodes such that neighbors get different colors Goal: minimize the number of colors Maximum matching: Matching: set of pair wise non adjacent edges Goal: maximize the size of the matching Algorithm Theory, WS 2012/13 Fabian Kuhn 3

4 Network Flow Flow Network: Directed graph,, Each (directed) edge has a capacity 0 Amount of flow (traffic) that the edge can carry A single source node and a single sink node Flow: (informally) Traffic from to such that each edge carries at most its capacity Examples: Highway system: edges are highways, flow is the traffic Computer network: edges are network links that can carry packets, nodes are switches Fluid network: edges are pipes that carry liquid Algorithm Theory, WS 2012/13 Fabian Kuhn 4

5 Network Flow: Definition Flow: function : is the amount of flow carried by edge Capacity Constraints: For each edge, Flow Conservation: For each node,, Flow Value:,, Algorithm Theory, WS 2012/13 Fabian Kuhn 5

6 Example: Flow Network Algorithm Theory, WS 2012/13 Fabian Kuhn 6

7 Notation We define:, For a set :, Flow conservation:, : Flow value: For simplicity: Assume that all capacities are positive integers Algorithm Theory, WS 2012/13 Fabian Kuhn 7

8 The Maximum Flow Problem Maximum Flow: Given a flow network, find a flow of maximum possible value Classical graph optimization problem Many applications (also beyond the obvious ones) Requires new algorithmic techniques Algorithm Theory, WS 2012/13 Fabian Kuhn 8

9 Maximum Flow: Greedy? Does greedy work? A natural greedy algorithm: As long as possible, find an path with free capacity and add as much flow as possible to the path Algorithm Theory, WS 2012/13 Fabian Kuhn 9

10 Improving the Greedy Solution Try to push 10 units of flow on edge, Too much incoming flow at : reduce flow on edge, Add that flow on edge, Algorithm Theory, WS 2012/13 Fabian Kuhn 10

11 Residual Graph Given a flow network, with capacities (for ) For a flow on, define directed graph, as follows: Node set For each edge, in, there are two edges in : forward edge, with residual capacity backward edge, with residual capacity Algorithm Theory, WS 2012/13 Fabian Kuhn 11

12 Residual Graph: Example Algorithm Theory, WS 2012/13 Fabian Kuhn 12

13 Residual Graph: Example Flow Algorithm Theory, WS 2012/13 Fabian Kuhn 13

14 Residual Graph: Example Residual Graph Algorithm Theory, WS 2012/13 Fabian Kuhn 14

15 Augmenting Path Residual Graph Algorithm Theory, WS 2012/13 Fabian Kuhn 15

16 Augmenting Path Augmenting Path Algorithm Theory, WS 2012/13 Fabian Kuhn 16

17 Augmenting Path New Flow Algorithm Theory, WS 2012/13 Fabian Kuhn 17

18 Augmenting Path Definition: An augmenting path is a (simple) path on the residual graph on which each edge has residual capacity 0. bottleneck, : minimum residual capacity on any edge of the augmenting path Augment flow to get flow : For every forward edge, on :,,, For every backward edge, on :,,, Algorithm Theory, WS 2012/13 Fabian Kuhn 18

19 Augmented Flow Lemma: Given a flow and an augmenting path, the resulting augmented flow is legal and its value is,. Proof: Algorithm Theory, WS 2012/13 Fabian Kuhn 19

20 Augmented Flow Lemma: Given a flow and an augmenting path, the resulting augmented flow is legal and its value is,. Proof: Algorithm Theory, WS 2012/13 Fabian Kuhn 20

21 Ford Fulkerson Algorithm Improve flow using an augmenting path as long as possible: 1. Initially, 0for all edges, 2. while there is an augmenting path in do 3. Let be an augmenting path in ; 4. augment, ; 5. update to be ; 6. update the residual graph 7. end; Algorithm Theory, WS 2012/13 Fabian Kuhn 21

22 Ford Fulkerson Running Time Theorem: If all edge capacities are integers, the Ford Fulkerson algorithm terminates after at most iterations, where. Proof: Algorithm Theory, WS 2012/13 Fabian Kuhn 22

23 Ford Fulkerson Running Time Theorem: If all edge capacities are integers, the Ford Fulkerson algorithm can be implemented to run in time. Proof: Algorithm Theory, WS 2012/13 Fabian Kuhn 23

24 Cuts Definition: An cut is a partition, of the vertex set such that and Algorithm Theory, WS 2012/13 Fabian Kuhn 24

25 Cut Capacity Definition: The capacity, of an cut, is defined as, Algorithm Theory, WS 2012/13 Fabian Kuhn 25

26 Cuts and Flow Value Lemma: Let be any flow, and, any cut. Then,. Proof: Algorithm Theory, WS 2012/13 Fabian Kuhn 26

27 Cuts and Flow Value Lemma: Let be any flow, and, any cut. Then,. Lemma: Let be any flow, and, any cut. Then,. Proof: Algorithm Theory, WS 2012/13 Fabian Kuhn 27

28 Upper Bound on Flow Value Lemma: Let be any flow and, and cut. Then,. Proof: Algorithm Theory, WS 2012/13 Fabian Kuhn 28

29 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

30 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

31 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

32 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

33 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

34 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

35 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

36 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

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

38 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

39 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

40 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

41 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

42 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

43 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

44 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 0for all, is a flow with value. Algorithm Theory, WS 2012/13 Fabian Kuhn 44

45 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

46 Compatible Labeling height 8 Arrows: edges of with positive residual capacity Algorithm Theory, WS 2012/13 Fabian Kuhn 46

47 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

48 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

49 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 :, 0for 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

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

51 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

52 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

53 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 ii. If capacities are integers, is an integer preflow iii. The preflow and the labeling are compatible If the algorithm terminates, is a maximum flow. Algorithm Theory, WS 2012/13 Fabian Kuhn 53

54 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

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

56 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

57 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

58 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

59 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

60 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

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

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

63 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

64 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

65 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

66 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

67 Edge Connectivity Definition: A graph, is edge connected for an integer 1if the graph, is connected for every edge set, 1. Goal: Compute edge connectivity of (and edge set of size that divides into 2parts) 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

68 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

69 Vertex Connectivity Definition: A graph, is vertex connected for an integer 1if 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 2parts) Compute minimum vertex cut for fixed and all Algorithm Theory, WS 2012/13 Fabian Kuhn 69

70 Edge Disjoint Paths Given: Graph, with nodes, Goal: Find as many edge disjoint paths as possible Solution: Find max flow in with edge capacities 1for 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

71 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 1for 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

72 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

73 Baseball Elimination Team Wins Losses To Play Against = l NY Balt. T. Bay Tor. Bost. New York Baltimore Tampa Bay Toronto Boston 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

74 Baseball Elimination Team Wins Losses To Play Against = l NY Balt. T. Bay Tor. Bost. New York Baltimore Tampa Bay Toronto Boston Can Toronto still finish first? Toronto can get 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

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

76 Reason for Elimination AL East: Aug 30, 1996 Team Wins Losses To Play Against = l NY Balt. Bost. Tor. Detr. New York Baltimore Boston Toronto Detroit Detroit could finish with wins Consider NY, Bal, Bos, Tor Have together already won 278 games Must together win at least 27more games On average, teams in win games Algorithm Theory, WS 2012/13 Fabian Kuhn 76

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

78 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

79 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

80 Circulations with Demands: Formally Given: Directed network, with Edge capacities 0for 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

81 Example Algorithm Theory, WS 2012/13 Fabian Kuhn 81

82 Condition on Demands Claim: If there exists a feasible circulation with demands for, then Proof: 0. 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

83 Reduction to Maximum Flow Add super source and super sink to network 0 0 supplies sources with flow siphons flow out of sinks Algorithm Theory, WS 2012/13 Fabian Kuhn 83

84 Example Algorithm Theory, WS 2012/13 Fabian Kuhn 84

85 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

86 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

87 Circulation: Demands and Lower Bounds Given: Directed network, with Edge capacities 0and lower bounds l 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: : l Demand Conditions: : Objective: Does a flow satisfying all conditions exist? If yes, find such a flow. Algorithm Theory, WS 2012/13 Fabian Kuhn 87

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

89 Eliminating a Lower Bound: Example Lower bound of Algorithm Theory, WS 2012/13 Fabian Kuhn 89

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

91 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, l is circulation in The capacity constraints are satisfied because l Demand conditions: l l Given circulation in, l is circulation in The capacity constraints are satisfied because l Demand conditions: l l Algorithm Theory, WS 2012/13 Fabian Kuhn 91

92 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

93 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: original data possible rounding Algorithm Theory, WS 2012/13 Fabian Kuhn 93

94 Matrix Rounding Theorem: For any matrix, there exists a feasible rounding. Remark: Just rounding to the nearest integer doesn t work original data rounding to nearest integer feasible rounding Algorithm Theory, WS 2012/13 Fabian Kuhn 94

95 Reduction to Circulation Matrix elements and row/column sums give a feasible circulation that satisfies all lower bound, capacity, and demand constraints rows: 3,4 columns: 12,13 2,3 10,11 all demands 0 Algorithm Theory, WS 2012/13 Fabian Kuhn 95

96 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

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

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

99 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

100 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

101 Santa s Problem Maximum Matching in Bipartite Graphs: Every child can get a gift iff there is a matching of size #children Clearly, every matching is at most as big If #children #gifts, there is a solution iff there is a perfect matching Algorithm Theory, WS 2012/13 Fabian Kuhn 101

102 Reducing to Maximum Flow Like edge disjoint paths all capacities are Algorithm Theory, WS 2012/13 Fabian Kuhn 102

103 Reducing to Maximum Flow Theorem: Every integer solution to the max flow problem on the constructed graph induces a maximum bipartite matching of. Proof: 1. A flow of value induces a matching of size Left nodes (gifts) have incoming capacity 1 Right nodes (children) have outgoing capacity 1 Left and right nodes are incident to 1edge of with 1 2. A matching of size implies a flow of value For each edge, of the matching:,,, 1 All other flow values are 0 Algorithm Theory, WS 2012/13 Fabian Kuhn 103

104 Running Time of Max. Bipartite Matching Theorem: A maximum matching of a bipartite graph can be computed in time Algorithm Theory, WS 2012/13 Fabian Kuhn 104

105 Perfect Matching? There can only be a perfect matching if both sides of the partition have size. There is no perfect matching, iff there is an cut of size in the flow network. 2 2 Algorithm Theory, WS 2012/13 Fabian Kuhn 105

106 Cuts Partition, of node set such that and If : edge, is in cut, If : edge, is in cut, Otherwise (if, ), all edges from to some are in cut, Algorithm Theory, WS 2012/13 Fabian Kuhn 106

107 Hall s Marriage Theorem Theorem: A bipartite graph, for which has a perfect matching if and only if :, where is the set of neighbors of nodes in. Proof: No perfect matching some cut has capacity 1. Assume there is for which U : Algorithm Theory, WS 2012/13 Fabian Kuhn 107

108 Hall s Marriage Theorem Theorem: A bipartite graph, for which has a perfect matching if and only if :, where is the set of neighbors of nodes in. Proof: No perfect matching some cut has capacity 2. Assume that there is a cut, of capacity Algorithm Theory, WS 2012/13 Fabian Kuhn 108

109 Hall s Marriage Theorem Theorem: A bipartite graph, for which has a perfect matching if and only if :, where is the set of neighbors of nodes in. Proof: No perfect matching some cut has capacity 2. Assume that there is a cut, of capacity Algorithm Theory, WS 2012/13 Fabian Kuhn 109

110 What About General Graphs Can we efficiently compute a maximum matching if is not bipartitie? How good is a maximal matching? A matching that cannot be extended Vertex Cover: set of nodes such that,,,. A vertex cover covers all edges by incident nodes Algorithm Theory, WS 2012/13 Fabian Kuhn 110

111 Vertex Cover vs Matching Consider a matching and a vertex cover Claim: Proof: At least one node of every edge, is in Needs to be a different node for different edges from Algorithm Theory, WS 2012/13 Fabian Kuhn 111

112 Vertex Cover vs Matching Consider a matching and a vertex cover Claim: If is maximal and is minimum, 2 Proof: is maximal: for every edge,, either or (or both) are matched Every edge is covered by at least one matching edge Thus, the set of the nodes of all matching edges gives a vertex cover of size 2. Algorithm Theory, WS 2012/13 Fabian Kuhn 112

113 Maximal Matching Approximation Theorem: For any maximal matching and any maximum matching, it holds that Proof: 2. Theorem: The set of all matched nodes of a maximal matching is a vertex cover of size at most twice the size of a min. vertex cover. Algorithm Theory, WS 2012/13 Fabian Kuhn 113

114 Augmenting Paths Consider a matching of a graph, : A node is called free iff it is not matched Augmenting Path: A (odd length) path that starts and ends at a free node and visits edges in and edges in alternatingly. free nodes alternating path Matching can be improved using an augmenting path by switching the role of each edge along the path Algorithm Theory, WS 2012/13 Fabian Kuhn 114

115 Augmenting Paths Theorem: A matching of, is maximum if and only if there is no augmenting path. Proof: Consider non max. matching and max. matching and define, Note that and Each node is incident to at most one edge in both and induces even cycles and paths Algorithm Theory, WS 2012/13 Fabian Kuhn 115

116 Finding Augmenting Paths free nodes augmenting path odd cycle Algorithm Theory, WS 2012/13 Fabian Kuhn 116

117 Blossoms If we find an odd cycle free node Graph Matching stem root contract blossom contracted blossom Graph blossom Matching, is a matching of. Algorithm Theory, WS 2012/13 Fabian Kuhn 117

118 Contracting Blossoms Lemma: Graph has an augmenting path w.r.t. matching iff has an augmenting path w.r.t. matching Note: If stem has length 0, root of blossom if free and thus also the node is free in. Also: The matching can be computed efficiently from. Algorithm Theory, WS 2012/13 Fabian Kuhn 118

119 Edmond s Blossom Algorithm Algorithm Sketch: 1. Build a tree for each free node 2. Starting from an explored node at even distance from a free node in the tree of, explore some unexplored edge, : 1. If is an unexplored node, is matched to some neighbor : add to the tree ( is now explored) 2. If is explored and in the same tree: at odd distance from root ignore and move on at even distance from root blossom found 3. If is explored and in another tree at odd distance from root ignore and move on at even distance from root augmenting path found Algorithm Theory, WS 2012/13 Fabian Kuhn 119

120 Running Time Finding a Blossom: Repeat on smaller graph Finding an Augmenting Path: Improve matching Theorem: The algorithm can be implemented in time. Algorithm Theory, WS 2012/13 Fabian Kuhn 120

121 Matching Algorithms We have seen: time alg. to compute a max. matching in bipartite graphs time alg. to compute a max. matching in general graphs Better algorithms: Best known running time (bipartite and general gr.): Weighted matching: Edges have weight, find a matching of maximum total weight Bipartite graphs: flow reduction works in the same way General graphs: can also be solved in polynomial time (Edmond s algorithms is used as blackbox) Algorithm Theory, WS 2012/13 Fabian Kuhn 121

122 Happy Holidays! Algorithm Theory, WS 2012/13 Fabian Kuhn 122

Graph Algorithms Matching

Graph Algorithms Matching Chapter 5 Graph Algorithms Matching Algorithm Theory WS 2012/13 Fabian Kuhn Circulation: Demands and Lower Bounds Given: Directed network, with Edge capacities 0and lower bounds l for Node demands for

More information

Graph Algorithms Maximum Flow Applications

Graph Algorithms Maximum Flow Applications Chapter 5 Graph Algorithms Maximum Flow Applications Algorithm Theory WS 202/3 Fabian Kuhn Maximum Flow Applications Maximum flow has many applications Reducing a problem to a max flow problem can even

More information

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

Tutorial for Algorithm s Theory Problem Set 5. January 17, 2013 Tutorial for Algorithm s Theory Problem Set 5 January 17, 2013 Exercise 1: Maximum Flow Algorithms Consider the following flow network: a) Solve the maximum flow problem on the above network by using the

More information

Approximation Algorithms

Approximation Algorithms Chapter 8 Approximation Algorithms Algorithm Theory WS 2016/17 Fabian Kuhn Approximation Algorithms Optimization appears everywhere in computer science We have seen many examples, e.g.: scheduling jobs

More information

Lecture 11: Maximum flow and minimum cut

Lecture 11: Maximum flow and minimum cut Optimisation Part IB - Easter 2018 Lecture 11: Maximum flow and minimum cut Lecturer: Quentin Berthet 4.4. The maximum flow problem. We consider in this lecture a particular kind of flow problem, with

More information

Maximum flows & Maximum Matchings

Maximum flows & Maximum Matchings Chapter 9 Maximum flows & Maximum Matchings This chapter analyzes flows and matchings. We will define flows and maximum flows and present an algorithm that solves the maximum flow problem. Then matchings

More information

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

Jessica Su (some parts copied from CLRS / last quarter s notes) 1 Max flow Consider a directed graph G with positive edge weights c that define the capacity of each edge. We can identify two special nodes in G: the source node s and the sink node t. We want to find

More information

Matching Algorithms. Proof. If a bipartite graph has a perfect matching, then it is easy to see that the right hand side is a necessary condition.

Matching Algorithms. Proof. If a bipartite graph has a perfect matching, then it is easy to see that the right hand side is a necessary condition. 18.433 Combinatorial Optimization Matching Algorithms September 9,14,16 Lecturer: Santosh Vempala Given a graph G = (V, E), a matching M is a set of edges with the property that no two of the edges have

More information

Today. Maximum flow. Maximum flow. Problem

Today. Maximum flow. Maximum flow. Problem 5 Maximum Flow (slides 1 4) Today Maximum flow Algorithms and Networks 2008 Maximum flow problem Applications Briefly: Ford-Fulkerson; min cut max flow theorem Preflow push algorithm Lift to front algorithm

More information

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

Outline: Finish uncapacitated simplex method Negative cost cycle algorithm The max-flow problem Max-flow min-cut theorem Outline: Finish uncapacitated simplex method Negative cost cycle algorithm The max-flow problem Max-flow min-cut theorem Uncapacitated Networks: Basic primal and dual solutions Flow conservation constraints

More information

Lecture 3: Graphs and flows

Lecture 3: Graphs and flows Chapter 3 Lecture 3: Graphs and flows Graphs: a useful combinatorial structure. Definitions: graph, directed and undirected graph, edge as ordered pair, path, cycle, connected graph, strongly connected

More information

LECTURES 3 and 4: Flows and Matchings

LECTURES 3 and 4: Flows and Matchings LECTURES 3 and 4: Flows and Matchings 1 Max Flow MAX FLOW (SP). Instance: Directed graph N = (V,A), two nodes s,t V, and capacities on the arcs c : A R +. A flow is a set of numbers on the arcs such that

More information

In this lecture, we ll look at applications of duality to three problems:

In this lecture, we ll look at applications of duality to three problems: Lecture 7 Duality Applications (Part II) In this lecture, we ll look at applications of duality to three problems: 1. Finding maximum spanning trees (MST). We know that Kruskal s algorithm finds this,

More information

CSE 417 Network Flows (pt 4) Min Cost Flows

CSE 417 Network Flows (pt 4) Min Cost Flows CSE 417 Network Flows (pt 4) Min Cost Flows Reminders > HW6 is due Monday Review of last three lectures > Defined the maximum flow problem find the feasible flow of maximum value flow is feasible if it

More information

CS261: Problem Set #1

CS261: Problem Set #1 CS261: Problem Set #1 Due by 11:59 PM on Tuesday, April 21, 2015 Instructions: (1) Form a group of 1-3 students. You should turn in only one write-up for your entire group. (2) Turn in your solutions by

More information

Graph Theory: Matchings and Factors

Graph Theory: Matchings and Factors Graph Theory: Matchings and Factors Pallab Dasgupta, Professor, Dept. of Computer Sc. and Engineering, IIT Kharagpur pallab@cse.iitkgp.ernet.in Matchings A matching of size k in a graph G is a set of k

More information

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

Graphs and Network Flows IE411. Lecture 13. Dr. Ted Ralphs Graphs and Network Flows IE411 Lecture 13 Dr. Ted Ralphs IE411 Lecture 13 1 References for Today s Lecture IE411 Lecture 13 2 References for Today s Lecture Required reading Sections 21.1 21.2 References

More information

Matching and Covering

Matching and Covering Matching and Covering Matchings A matching of size k in a graph G is a set of k pairwise disjoint edges The vertices belonging to the edges of a matching are saturated by the matching; the others are unsaturated

More information

and 6.855J March 6, Maximum Flows 2

and 6.855J March 6, Maximum Flows 2 5.08 and.855j March, 00 Maximum Flows Network Reliability Communication Network What is the maximum number of arc disjoint paths from s to t? How can we determine this number? Theorem. Let G = (N,A) be

More information

Network Design and Optimization course

Network Design and Optimization course Effective maximum flow algorithms Modeling with flows Network Design and Optimization course Lecture 5 Alberto Ceselli alberto.ceselli@unimi.it Dipartimento di Tecnologie dell Informazione Università degli

More information

GRAPH DECOMPOSITION BASED ON DEGREE CONSTRAINTS. March 3, 2016

GRAPH DECOMPOSITION BASED ON DEGREE CONSTRAINTS. March 3, 2016 GRAPH DECOMPOSITION BASED ON DEGREE CONSTRAINTS ZOÉ HAMEL March 3, 2016 1. Introduction Let G = (V (G), E(G)) be a graph G (loops and multiple edges not allowed) on the set of vertices V (G) and the set

More information

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

Network Flow. November 23, CMPE 250 Graphs- Network Flow November 23, / 31 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

More information

Bipartite Matching & the Hungarian Method

Bipartite Matching & the Hungarian Method Bipartite Matching & the Hungarian Method Last Revised: 15/9/7 These notes follow formulation originally developed by Subhash Suri in http://www.cs.ucsb.edu/ suri/cs/matching.pdf We previously saw how

More information

Paths, Flowers and Vertex Cover

Paths, Flowers and Vertex Cover Paths, Flowers and Vertex Cover Venkatesh Raman, M.S. Ramanujan, and Saket Saurabh Presenting: Hen Sender 1 Introduction 2 Abstract. It is well known that in a bipartite (and more generally in a Konig)

More information

PERFECT MATCHING THE CENTRALIZED DEPLOYMENT MOBILE SENSORS THE PROBLEM SECOND PART: WIRELESS NETWORKS 2.B. SENSOR NETWORKS OF MOBILE SENSORS

PERFECT MATCHING THE CENTRALIZED DEPLOYMENT MOBILE SENSORS THE PROBLEM SECOND PART: WIRELESS NETWORKS 2.B. SENSOR NETWORKS OF MOBILE SENSORS SECOND PART: WIRELESS NETWORKS 2.B. SENSOR NETWORKS THE CENTRALIZED DEPLOYMENT OF MOBILE SENSORS I.E. THE MINIMUM WEIGHT PERFECT MATCHING 1 2 ON BIPARTITE GRAPHS Prof. Tiziana Calamoneri Network Algorithms

More information

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

CSE 417 Network Flows (pt 3) Modeling with Min Cuts CSE 417 Network Flows (pt 3) Modeling with Min Cuts Reminders > HW6 is due on Friday start early bug fixed on line 33 of OptimalLineup.java: > change true to false Review of last two lectures > Defined

More information

Classic Graph Theory Problems

Classic Graph Theory Problems Classic Graph Theory Problems Hiroki Sayama sayama@binghamton.edu The Origin Königsberg bridge problem Pregel River (Solved negatively by Euler in 176) Representation in a graph Can all the seven edges

More information

Datenstrukturen & Algorithmen Solution of Sheet 11 FS 14

Datenstrukturen & Algorithmen Solution of Sheet 11 FS 14 Eidgenössische Technische Hochschule Zürich Ecole polytechnique fédérale de Zurich Politecnico federale di Zurigo Federal Institute of Technology at Zurich Institut für Theoretische Informatik 14th May

More information

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

Lecture 10,11: General Matching Polytope, Maximum Flow. 1 Perfect Matching and Matching Polytope on General Graphs CMPUT 675: Topics in Algorithms and Combinatorial Optimization (Fall 2009) Lecture 10,11: General Matching Polytope, Maximum Flow Lecturer: Mohammad R Salavatipour Date: Oct 6 and 8, 2009 Scriber: Mohammad

More information

Matching Theory. Figure 1: Is this graph bipartite?

Matching Theory. Figure 1: Is this graph bipartite? Matching Theory 1 Introduction A matching M of a graph is a subset of E such that no two edges in M share a vertex; edges which have this property are called independent edges. A matching M is said to

More information

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

Copyright 2007 Pearson Addison-Wesley. All rights reserved. A. Levitin Introduction to the Design & Analysis of Algorithms, 2 nd ed., Ch. Iterative Improvement Algorithm design technique for solving optimization problems Start with a feasible solution Repeat the following step until no improvement can be found: change the current feasible

More information

Network flows and Menger s theorem

Network flows and Menger s theorem Network flows and Menger s theorem Recall... Theorem (max flow, min cut strong duality). Let G be a network. The maximum value of a flow equals the minimum capacity of a cut. We prove this strong duality

More information

Solutions for the Exam 6 January 2014

Solutions for the Exam 6 January 2014 Mastermath and LNMB Course: Discrete Optimization Solutions for the Exam 6 January 2014 Utrecht University, Educatorium, 13:30 16:30 The examination lasts 3 hours. Grading will be done before January 20,

More information

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

Source. Sink. Chapter 10: Iterative Programming Maximum Flow Problem. CmSc250 Intro to Algorithms Chapter 10: Iterative Programming Maximum Flow Problem CmSc20 Intro to Algorithms A flow network is a model of a system where some material is produced at its source, travels through the system, and is

More information

val(y, I) α (9.0.2) α (9.0.3)

val(y, I) α (9.0.2) α (9.0.3) CS787: Advanced Algorithms Lecture 9: Approximation Algorithms In this lecture we will discuss some NP-complete optimization problems and give algorithms for solving them that produce a nearly optimal,

More information

Solving problems on graph algorithms

Solving problems on graph algorithms Solving problems on graph algorithms Workshop Organized by: ACM Unit, Indian Statistical Institute, Kolkata. Tutorial-3 Date: 06.07.2017 Let G = (V, E) be an undirected graph. For a vertex v V, G {v} is

More information

6. Lecture notes on matroid intersection

6. Lecture notes on matroid intersection Massachusetts Institute of Technology 18.453: Combinatorial Optimization Michel X. Goemans May 2, 2017 6. Lecture notes on matroid intersection One nice feature about matroids is that a simple greedy algorithm

More information

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

COT 6936: Topics in Algorithms! Giri Narasimhan. ECS 254A / EC 2443; Phone: x3748 COT 6936: Topics in Algorithms! Giri Narasimhan ECS 254A / EC 2443; Phone: x3748 giri@cs.fiu.edu http://www.cs.fiu.edu/~giri/teach/cot6936_s12.html https://moodle.cis.fiu.edu/v2.1/course/view.php?id=174

More information

Network Flow. The network flow problem is as follows:

Network Flow. The network flow problem is as follows: 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), and two distinguished

More information

Theorem 2.9: nearest addition algorithm

Theorem 2.9: nearest addition algorithm There are severe limits on our ability to compute near-optimal tours It is NP-complete to decide whether a given undirected =(,)has a Hamiltonian cycle An approximation algorithm for the TSP can be used

More information

Maximum Flow Algorithms

Maximum Flow Algorithms Maximum Flow Algorithms Network Algorithms Georgia Kaouri Contents Applications, special cases Flow networks Ford Fulkerson algorithm Preflow push algorithms Lift to front algorithm Material flows Applications

More information

Paths, Flowers and Vertex Cover

Paths, Flowers and Vertex Cover Paths, Flowers and Vertex Cover Venkatesh Raman M. S. Ramanujan Saket Saurabh Abstract It is well known that in a bipartite (and more generally in a König) graph, the size of the minimum vertex cover is

More information

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

Graphs. Edges may be directed (from u to v) or undirected. Undirected edge eqvt to pair of directed edges (p 186) Graphs G = (V,E) Graphs set V of vertices, each with a unique name Note: book calls vertices as nodes set E of edges between vertices, each encoded as tuple of 2 vertices as in (u,v) Edges may

More information

CMPSCI611: The SUBSET-SUM Problem Lecture 18

CMPSCI611: The SUBSET-SUM Problem Lecture 18 CMPSCI611: The SUBSET-SUM Problem Lecture 18 We begin today with the problem we didn t get to at the end of last lecture the SUBSET-SUM problem, which we also saw back in Lecture 8. The input to SUBSET-

More information

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

Sources for this lecture. 3. Matching in bipartite and general graphs. Symmetric difference S-72.2420 / T-79.5203 Matching in bipartite and general graphs 1 3. Matching in bipartite and general graphs Let G be a graph. A matching M in G is a set of nonloop edges with no shared endpoints. Let

More information

Traveling Salesman Problem (TSP) Input: undirected graph G=(V,E), c: E R + Goal: find a tour (Hamiltonian cycle) of minimum cost

Traveling Salesman Problem (TSP) Input: undirected graph G=(V,E), c: E R + Goal: find a tour (Hamiltonian cycle) of minimum cost Traveling Salesman Problem (TSP) Input: undirected graph G=(V,E), c: E R + Goal: find a tour (Hamiltonian cycle) of minimum cost Traveling Salesman Problem (TSP) Input: undirected graph G=(V,E), c: E R

More information

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

Network Flows. 1. Flows deal with network models where edges have capacity constraints. 2. Shortest paths deal with edge costs. Network Flows. Flows deal with network models where edges have capacity constraints. 2. Shortest paths deal with edge costs. 4 u v 2 5 s 6 5 t 4 x 2 y 3 3. Network flow formulation: A network G = (V, E).

More information

Jörgen Bang-Jensen and Gregory Gutin. Digraphs. Theory, Algorithms and Applications. Springer

Jörgen Bang-Jensen and Gregory Gutin. Digraphs. Theory, Algorithms and Applications. Springer Jörgen Bang-Jensen and Gregory Gutin Digraphs Theory, Algorithms and Applications Springer Contents 1. Basic Terminology, Notation and Results 1 1.1 Sets, Subsets, Matrices and Vectors 1 1.2 Digraphs,

More information

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

Graphs and Network Flows IE411. Lecture 21. Dr. Ted Ralphs Graphs and Network Flows IE411 Lecture 21 Dr. Ted Ralphs IE411 Lecture 21 1 Combinatorial Optimization and Network Flows In general, most combinatorial optimization and integer programming problems are

More information

7. NETWORK FLOW II. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013 Kevin Wayne

7. NETWORK FLOW II. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013 Kevin Wayne 7. NETWORK FLOW II Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 203 Kevin Wayne http://www.cs.princeton.edu/~wayne/kleinberg-tardos bipartite matching disjoint paths extensions

More information

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

Maximum Flow. Flow Networks. Flow Networks Ford-Fulkerson Method Edmonds-Karp Algorithm Push-Relabel Algorithms. Example Flow Network Flow Networks Ford-Fulkerson Method Edmonds-Karp Algorithm Push-Relabel Algorithms Maximum Flow Flow Networks A flow network is a directed graph where: Each edge (u,v) has a capacity c(u,v) 0. If (u,v)

More information

1 Matching in Non-Bipartite Graphs

1 Matching in Non-Bipartite Graphs CS 369P: Polyhedral techniques in combinatorial optimization Instructor: Jan Vondrák Lecture date: September 30, 2010 Scribe: David Tobin 1 Matching in Non-Bipartite Graphs There are several differences

More information

Minimum Cost Edge Disjoint Paths

Minimum Cost Edge Disjoint Paths Minimum Cost Edge Disjoint Paths Theodor Mader 15.4.2008 1 Introduction Finding paths in networks and graphs constitutes an area of theoretical computer science which has been highly researched during

More information

PERFECT MATCHING THE CENTRALIZED DEPLOYMENT MOBILE SENSORS THE PROBLEM SECOND PART: WIRELESS NETWORKS 2.B. SENSOR NETWORKS OF MOBILE SENSORS

PERFECT MATCHING THE CENTRALIZED DEPLOYMENT MOBILE SENSORS THE PROBLEM SECOND PART: WIRELESS NETWORKS 2.B. SENSOR NETWORKS OF MOBILE SENSORS SECOND PART: WIRELESS NETWORKS.B. SENSOR NETWORKS THE CENTRALIZED DEPLOYMENT OF MOBILE SENSORS I.E. THE MINIMUM WEIGHT PERFECT MATCHING ON BIPARTITE GRAPHS Prof. Tiziana Calamoneri Network Algorithms A.y.

More information

Solution for Homework set 3

Solution for Homework set 3 TTIC 300 and CMSC 37000 Algorithms Winter 07 Solution for Homework set 3 Question (0 points) We are given a directed graph G = (V, E), with two special vertices s and t, and non-negative integral capacities

More information

1 The Traveling Salesperson Problem (TSP)

1 The Traveling Salesperson Problem (TSP) CS 598CSC: Approximation Algorithms Lecture date: January 23, 2009 Instructor: Chandra Chekuri Scribe: Sungjin Im In the previous lecture, we had a quick overview of several basic aspects of approximation

More information

Notes for Lecture 20

Notes for Lecture 20 U.C. Berkeley CS170: Intro to CS Theory Handout N20 Professor Luca Trevisan November 13, 2001 Notes for Lecture 20 1 Duality As it turns out, the max-flow min-cut theorem is a special case of a more general

More information

Introduction to Graph Theory

Introduction to Graph Theory Introduction to Graph Theory Tandy Warnow January 20, 2017 Graphs Tandy Warnow Graphs A graph G = (V, E) is an object that contains a vertex set V and an edge set E. We also write V (G) to denote the vertex

More information

Graphs and Algorithms 2016

Graphs and Algorithms 2016 Graphs and Algorithms 2016 Teachers: Nikhil Bansal and Jesper Nederlof TA: Shashwat Garg (Office Hours: Thursday: Pick??) Webpage: www.win.tue.nl/~nikhil/courses/2wo08 (for up to date information, links

More information

CMPSCI 311: Introduction to Algorithms Practice Final Exam

CMPSCI 311: Introduction to Algorithms Practice Final Exam CMPSCI 311: Introduction to Algorithms Practice Final Exam Name: ID: Instructions: Answer the questions directly on the exam pages. Show all your work for each question. Providing more detail including

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 29 Approximation Algorithms Load Balancing Weighted Vertex Cover Reminder: Fill out SRTEs online Don t forget to click submit Sofya Raskhodnikova 12/7/2016 Approximation

More information

Induction Review. Graphs. EECS 310: Discrete Math Lecture 5 Graph Theory, Matching. Common Graphs. a set of edges or collection of two-elt subsets

Induction Review. Graphs. EECS 310: Discrete Math Lecture 5 Graph Theory, Matching. Common Graphs. a set of edges or collection of two-elt subsets EECS 310: Discrete Math Lecture 5 Graph Theory, Matching Reading: MIT OpenCourseWare 6.042 Chapter 5.1-5.2 Induction Review Basic Induction: Want to prove P (n). Prove base case P (1). Prove P (n) P (n+1)

More information

CPCS Discrete Structures 1

CPCS Discrete Structures 1 Let us switch to a new topic: Graphs CPCS 222 - Discrete Structures 1 Introduction to Graphs Definition: A simple graph G = (V, E) consists of V, a nonempty set of vertices, and E, a set of unordered pairs

More information

7. NETWORK FLOW II. bipartite matching disjoint paths extensions to max flow survey design airline scheduling image segmentation project selection

7. NETWORK FLOW II. bipartite matching disjoint paths extensions to max flow survey design airline scheduling image segmentation project selection 7. NETWORK FLOW II bipartite matching disjoint paths extensions to max flow survey design airline scheduling image segmentation project selection Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison

More information

CSC 8301 Design & Analysis of Algorithms: Linear Programming

CSC 8301 Design & Analysis of Algorithms: Linear Programming CSC 8301 Design & Analysis of Algorithms: Linear Programming Professor Henry Carter Fall 2016 Iterative Improvement Start with a feasible solution Improve some part of the solution Repeat until the solution

More information

12 Introduction to LP-Duality

12 Introduction to LP-Duality 12 Introduction to LP-Duality A large fraction of the theory of approximation algorithms, as we know it today, is built around linear programming (LP). In Section 12.1 we will review some key concepts

More information

by conservation of flow, hence the cancelation. Similarly, we have

by conservation of flow, hence the cancelation. Similarly, we have Chapter 13: Network Flows and Applications Network: directed graph with source S and target T. Non-negative edge weights represent capacities. Assume no edges into S or out of T. (If necessary, we can

More information

CS261: A Second Course in Algorithms Lecture #3: The Push-Relabel Algorithm for Maximum Flow

CS261: A Second Course in Algorithms Lecture #3: The Push-Relabel Algorithm for Maximum Flow CS26: A Second Course in Algorithms Lecture #3: The Push-Relabel Algorithm for Maximum Flow Tim Roughgarden January 2, 206 Motivation The maximum flow algorithms that we ve studied so far are augmenting

More information

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

Module 7. Independent sets, coverings. and matchings. Contents Module 7 Independent sets, coverings Contents and matchings 7.1 Introduction.......................... 152 7.2 Independent sets and coverings: basic equations..... 152 7.3 Matchings in bipartite graphs................

More information

Approximation Algorithms

Approximation Algorithms Approximation Algorithms Given an NP-hard problem, what should be done? Theory says you're unlikely to find a poly-time algorithm. Must sacrifice one of three desired features. Solve problem to optimality.

More information

CSE 417 Branch & Bound (pt 4) Branch & Bound

CSE 417 Branch & Bound (pt 4) Branch & Bound CSE 417 Branch & Bound (pt 4) Branch & Bound Reminders > HW8 due today > HW9 will be posted tomorrow start early program will be slow, so debugging will be slow... Review of previous lectures > Complexity

More information

CS261: A Second Course in Algorithms Lecture #16: The Traveling Salesman Problem

CS261: A Second Course in Algorithms Lecture #16: The Traveling Salesman Problem CS61: A Second Course in Algorithms Lecture #16: The Traveling Salesman Problem Tim Roughgarden February 5, 016 1 The Traveling Salesman Problem (TSP) In this lecture we study a famous computational problem,

More information

Matching. Algorithms and Networks

Matching. Algorithms and Networks Matching Algorithms and Networks This lecture Matching: problem statement and applications Bipartite matching (recap) Matching in arbitrary undirected graphs: Edmonds algorithm Diversion: generalized tic-tac-toe

More information

15-451/651: Design & Analysis of Algorithms November 4, 2015 Lecture #18 last changed: November 22, 2015

15-451/651: Design & Analysis of Algorithms November 4, 2015 Lecture #18 last changed: November 22, 2015 15-451/651: Design & Analysis of Algorithms November 4, 2015 Lecture #18 last changed: November 22, 2015 While we have good algorithms for many optimization problems, the previous lecture showed that many

More information

Exercise set 2 Solutions

Exercise set 2 Solutions Exercise set 2 Solutions Let H and H be the two components of T e and let F E(T ) consist of the edges of T with one endpoint in V (H), the other in V (H ) Since T is connected, F Furthermore, since T

More information

Reducing Directed Max Flow to Undirected Max Flow and Bipartite Matching

Reducing Directed Max Flow to Undirected Max Flow and Bipartite Matching Reducing Directed Max Flow to Undirected Max Flow and Bipartite Matching Henry Lin Division of Computer Science University of California, Berkeley Berkeley, CA 94720 Email: henrylin@eecs.berkeley.edu Abstract

More information

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18 601.433/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18 22.1 Introduction We spent the last two lectures proving that for certain problems, we can

More information

Notes for Lecture 24

Notes for Lecture 24 U.C. Berkeley CS170: Intro to CS Theory Handout N24 Professor Luca Trevisan December 4, 2001 Notes for Lecture 24 1 Some NP-complete Numerical Problems 1.1 Subset Sum The Subset Sum problem is defined

More information

The Encoding Complexity of Network Coding

The Encoding Complexity of Network Coding The Encoding Complexity of Network Coding Michael Langberg Alexander Sprintson Jehoshua Bruck California Institute of Technology Email: mikel,spalex,bruck @caltech.edu Abstract In the multicast network

More information

Preflow-Push Algorithm

Preflow-Push Algorithm Preflow-Push Algorithm An s-t preflow obeys the following constraints: Capacity constraints: 0 f(e) c(e) e f (v) = f (u,v) f (v,w) 0 u V w V A labeling h assigns nonnegative integers to vertices. h(t)

More information

MTL 776: Graph Algorithms Lecture : Matching in Graphs

MTL 776: Graph Algorithms Lecture : Matching in Graphs MTL 776: Graph Algorithms Lecture : Matching in Graphs Course Coordinator: Prof. B. S. Panda Note: The note is based on the lectures taken in the class. It is a draft version and may contain errors. It

More information

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018 CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018 Chapter 11 Approximation Algorithms Slides by Kevin Wayne. Copyright @ 2005 Pearson-Addison Wesley. All rights reserved.

More information

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. An Introduction to Graph Theory

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. An Introduction to Graph Theory SCHOOL OF ENGINEERING & BUILT ENVIRONMENT Mathematics An Introduction to Graph Theory. Introduction. Definitions.. Vertices and Edges... The Handshaking Lemma.. Connected Graphs... Cut-Points and Bridges.

More information

CS261: Problem Set #2

CS261: Problem Set #2 CS261: Problem Set #2 Due by 11:59 PM on Tuesday, February 9, 2016 Instructions: (1) Form a group of 1-3 students. You should turn in only one write-up for your entire group. (2) Submission instructions:

More information

Strongly connected: A directed graph is strongly connected if every pair of vertices are reachable from each other.

Strongly connected: A directed graph is strongly connected if every pair of vertices are reachable from each other. Directed Graph In a directed graph, each edge (u, v) has a direction u v. Thus (u, v) (v, u). Directed graph is useful to model many practical problems (such as one-way road in traffic network, and asymmetric

More information

Homework 3 Solutions

Homework 3 Solutions CS3510 Design & Analysis of Algorithms Section A Homework 3 Solutions Released: 7pm, Wednesday Nov 8, 2017 This homework has a total of 4 problems on 4 pages. Solutions should be submitted to GradeScope

More information

1. Lecture notes on bipartite matching February 4th,

1. Lecture notes on bipartite matching February 4th, 1. Lecture notes on bipartite matching February 4th, 2015 6 1.1.1 Hall s Theorem Hall s theorem gives a necessary and sufficient condition for a bipartite graph to have a matching which saturates (or matches)

More information

Notes for Recitation 9

Notes for Recitation 9 6.042/18.062J Mathematics for Computer Science October 8, 2010 Tom Leighton and Marten van Dijk Notes for Recitation 9 1 Traveling Salesperson Problem Now we re going to talk about a famous optimization

More information

1 Introduction. 2 The Generic Push-Relabel Algorithm. Improvements on the Push-Relabel Method: Excess Scaling. 2.1 Definitions CMSC 29700

1 Introduction. 2 The Generic Push-Relabel Algorithm. Improvements on the Push-Relabel Method: Excess Scaling. 2.1 Definitions CMSC 29700 CMSC 9700 Supervised Reading & Research Week 6: May 17, 013 Improvements on the Push-Relabel Method: Excess Scaling Rahul Mehta 1 Introduction We now know about both the methods based on the idea of Ford

More information

Assignment 1 Introduction to Graph Theory CO342

Assignment 1 Introduction to Graph Theory CO342 Assignment 1 Introduction to Graph Theory CO342 This assignment will be marked out of a total of thirty points, and is due on Thursday 18th May at 10am in class. Throughout the assignment, the graphs are

More information

Treewidth and graph minors

Treewidth and graph minors Treewidth and graph minors Lectures 9 and 10, December 29, 2011, January 5, 2012 We shall touch upon the theory of Graph Minors by Robertson and Seymour. This theory gives a very general condition under

More information

CPSC 536N: Randomized Algorithms Term 2. Lecture 10

CPSC 536N: Randomized Algorithms Term 2. Lecture 10 CPSC 536N: Randomized Algorithms 011-1 Term Prof. Nick Harvey Lecture 10 University of British Columbia In the first lecture we discussed the Max Cut problem, which is NP-complete, and we presented a very

More information

implementing the breadth-first search algorithm implementing the depth-first search algorithm

implementing the breadth-first search algorithm implementing the depth-first search algorithm Graph Traversals 1 Graph Traversals representing graphs adjacency matrices and adjacency lists 2 Implementing the Breadth-First and Depth-First Search Algorithms implementing the breadth-first search algorithm

More information

1 Undirected Vertex Geography UVG

1 Undirected Vertex Geography UVG Geography Start with a chip sitting on a vertex v of a graph or digraph G. A move consists of moving the chip to a neighbouring vertex. In edge geography, moving the chip from x to y deletes the edge (x,

More information

1. Lecture notes on bipartite matching

1. Lecture notes on bipartite matching Massachusetts Institute of Technology 18.453: Combinatorial Optimization Michel X. Goemans February 5, 2017 1. Lecture notes on bipartite matching Matching problems are among the fundamental problems in

More information

Matching 4/21/2016. Bipartite Matching. 3330: Algorithms. First Try. Maximum Matching. Key Questions. Existence of Perfect Matching

Matching 4/21/2016. Bipartite Matching. 3330: Algorithms. First Try. Maximum Matching. Key Questions. Existence of Perfect Matching Bipartite Matching Matching 3330: Algorithms A graph is bipartite if its vertex set can be partitioned into two subsets A and B so that each edge has one endpoint in A and the other endpoint in B. A B

More information

Lecture 3: Totally Unimodularity and Network Flows

Lecture 3: Totally Unimodularity and Network Flows Lecture 3: Totally Unimodularity and Network Flows (3 units) Outline Properties of Easy Problems Totally Unimodular Matrix Minimum Cost Network Flows Dijkstra Algorithm for Shortest Path Problem Ford-Fulkerson

More information

Lecture notes on: Maximum matching in bipartite and non-bipartite graphs (Draft)

Lecture notes on: Maximum matching in bipartite and non-bipartite graphs (Draft) Lecture notes on: Maximum matching in bipartite and non-bipartite graphs (Draft) Lecturer: Uri Zwick June 5, 2013 1 The maximum matching problem Let G = (V, E) be an undirected graph. A set M E is a matching

More information

CS521 \ Notes for the Final Exam

CS521 \ Notes for the Final Exam CS521 \ Notes for final exam 1 Ariel Stolerman Asymptotic Notations: CS521 \ Notes for the Final Exam Notation Definition Limit Big-O ( ) Small-o ( ) Big- ( ) Small- ( ) Big- ( ) Notes: ( ) ( ) ( ) ( )

More information

Elements of Graph Theory

Elements of Graph Theory Elements of Graph Theory Quick review of Chapters 9.1 9.5, 9.7 (studied in Mt1348/2008) = all basic concepts must be known New topics we will mostly skip shortest paths (Chapter 9.6), as that was covered

More information