3.5 Minimum Cuts in Undirected Graphs

Slides:



Advertisements
Similar presentations
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Advertisements

Lectures on Network Flows
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Totally Unimodular Matrices Lecture 11: Feb 23 Simplex Algorithm Elliposid Algorithm.
Gomory-Hu Tree for representation of minimum cuts Elad Avni.
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
Approximating Minimum Bounded Degree Spanning Tree (MBDST) Mohit Singh and Lap Chi Lau “Approximating Minimum Bounded DegreeApproximating Minimum Bounded.
Combinatorial Optimization Minimum Cuts in Undirected Graphs Global Minimum Cuts.
Edge-disjoint induced subgraphs with given minimum degree Raphael Yuster 2012.
 2004 SDU Lecture 7- Minimum Spanning Tree-- Extension 1.Properties of Minimum Spanning Tree 2.Secondary Minimum Spanning Tree 3.Bottleneck.
 Rooted tree and binary tree  Theorem 5.19: A full binary tree with t leaves contains i=t-1 internal vertices.
Introduction to Graph Theory
Flows in Planar Graphs Hadi Mahzarnia. Outline O Introduction O Planar single commodity flow O Multicommodity flows for C 1 O Feasibility O Algorithm.
Chapter 7 April 28 Network Flow.
Network Flows Chun-Ta, Yu Graduate Institute Information Management Dept. National Taiwan University.
Chapter 8 Maximum Flows: Additional Topics All-Pairs Minimum Value Cut Problem  Given an undirected network G, find minimum value cut for all.
Chapter 7 May 3 Ford-Fulkerson algorithm Step-by-step walk through of an example Worst-case number of augmentations Edmunds-Karp modification Time complexity.
1 Assignment #3 is posted: Due Thursday Nov. 15 at the beginning of class. Make sure you are also working on your projects. Come see me if you are unsure.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
C&O 355 Lecture 19 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A A A A A A A A.
5.6 Prefix codes and optimal tree Definition 31: Codes with this property which the bit string for a letter never occurs as the first part of the bit string.
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Trees.
Theory of Computational Complexity Probability and Computing Chapter Hikaru Inada Iwama and Ito lab M1.
V15: Max-Flow Min-Cut V15 continues chapter 12 in Gross & Yellen „Graph Theory“ Theorem [Characterization of Maximum Flow] Let f be a flow in a.
Lap Chi Lau we will only use slides 4 to 19
Markov Chains and Random Walks
Maximum Flow Chapter 26.
Topics in Algorithms Lap Chi Lau.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
The minimum cost flow problem
Minimum Spanning Tree 8/7/2018 4:26 AM
Algorithm Design and Analysis
Lectures on Network Flows
Proving that a Valid Inequality is Facet-defining
Lecture 12 Algorithm Analysis
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Chapter 5. Optimal Matchings
Greedy Algorithms / Interval Scheduling Yin Tat Lee
1.3 Modeling with exponentially many constr.
James B. Orlin Presented by Tal Kaminker
Discrete Mathematics for Computer Science
3.3 Applications of Maximum Flow and Minimum Cut
Enumerating Distances Using Spanners of Bounded Degree
Chap 3. The simplex method
Network Flow 2016/04/12.
3.4 Push-Relabel(Preflow-Push) Maximum Flow Alg.
Lecture 19-Problem Solving 4 Incremental Method
Vertex Covers, Matchings, and Independent Sets
2. Generating All Valid Inequalities
Problem Solving 4.
Max Flow Min Cut, Bipartite Matching Yin Tat Lee
2.2 Shortest Paths Def: directed graph or digraph
1.3 Modeling with exponentially many constr.
Systems of distinct representations
I.4 Polyhedral Theory (NW)
5.4 T-joins and Postman Problems
Algorithms (2IL15) – Lecture 7
Flow Feasibility Problems
離散數學 DISCRETE and COMBINATORIAL MATHEMATICS
V12 Menger’s theorem Borrowing terminology from operations research
I.4 Polyhedral Theory.
Proving that a Valid Inequality is Facet-defining
Part II General Integer Programming
Clustering.
Winter 2019 Lecture 11 Minimum Spanning Trees (Part II)
Chapter 2. Simplex method
Vertex Covers and Matchings
Minimum Spanning Trees
Autumn 2019 Lecture 11 Minimum Spanning Trees (Part II)
Presentation transcript:

3.5 Minimum Cuts in Undirected Graphs 3.5.1 Global Minimum Cuts Given connected undirected graph 𝐺=(𝑉,𝐸), capacity 𝑢∈𝑅𝐸 (𝑢𝑒>0), find 𝑆⊆𝑉 with ∅≠𝑆≠𝑉 such that 𝑢((𝑆)) is minimum. (When each 𝑢 𝑒 =1, the minimum is “edge-connectivity” of 𝐺.) Def: 𝑣, 𝑤 of 𝐺 are separated by a cut (𝑆), or (𝑆) is a (𝑣, 𝑤)-cut if exactly one of 𝑣, 𝑤 is in 𝑆. To find min (𝑣, 𝑤)-cut in an undirected graph, we can replace each edge by two oppositely directed arcs and give same capacities as the edge, then solve max flow problem. (When 𝑢 𝑒 =1  edge connectivity of 𝐺) If we fix some node 𝑟, then any cut is (𝑟, 𝑠)-cut for some node 𝑠∈𝑉∖{𝑟} ⇒ Solve 𝑛−1 min (𝑟, 𝑠)-cut problem for 𝑠∈𝑉∖{𝑟} and take min of them. ⇒ 𝑂(𝑛4) But other direct method exists with 𝑂(𝑛3) running time. Combinatorial Optimization 2016

(𝐺) : capacity of a min cut of 𝐺. Definition: (𝐺) : capacity of a min cut of 𝐺. (𝐺; 𝑣, 𝑤) : capacity of a minimum (𝑣, 𝑤)-cut of 𝐺 𝐺𝑣𝑤 is a graph obtained by identifying node 𝑣 with 𝑤. ( 𝑣, 𝑤 distinct nodes) ( 𝑉(𝐺𝑣𝑤)=(𝑉∖{𝑣, 𝑤})∪{𝑥}, where 𝑥 is a new node, 𝐸(𝐺𝑣𝑤)=𝐸∖({𝑣, 𝑤}); for each 𝑒∈𝐸 and end 𝑝 of 𝑒 in 𝐺, 𝑝 is an end of 𝐺𝑣𝑤 if 𝑝≠𝑣, 𝑤, otherwise 𝑥 is an end of 𝑒 in 𝐺𝑣𝑤. capacities are the same) (If multiple edges created, may replace them with an edge with total capacities. For ease of exposition, we do not do this.) Combinatorial Optimization 2016

b b 3 3 5 5 c a c a 2 2 2 2 4 3 4 3 h h 1 d 3 1 d 3 e e 2 2 2 2 5 5 6 g f x Identifying nodes f, g Combinatorial Optimization 2016

Continue 𝑛−2 times on smaller graphs. Prop 3.35: Every cut of 𝐺𝑣𝑤 is a cut of 𝐺. Every cut of 𝐺 that does not separate 𝑣 from 𝑤 is a cut of 𝐺𝑣𝑤. In 𝐺𝑣𝑤, each cut corresponds to a cut in 𝐺 having 𝑣 and 𝑤 in one side of the cut. Hence, if we can find the min cut among the cuts that separate 𝑣 and 𝑤, we can compare the value with the min cut value in 𝐺𝑣𝑤. Straightforward implementation: solve min (𝑣, 𝑤)-cut for any 𝑣, 𝑤. Then identity 𝑣 with 𝑤 and solve min cut on 𝐺𝑣𝑤 again. Continue 𝑛−2 times on smaller graphs. Small improvement, but not significant. make smart choice of 𝑣, 𝑤. Combinatorial Optimization 2016

Node Identification Algorithm rationale: 𝜆(𝐺)= min ((𝐺𝑣𝑤), (𝐺; 𝑣, 𝑤)) Need to find a min cut separating 𝑣, 𝑤 (using max flow algorithm after doubling arcs, need 𝑛−1 times ). However, choosing 𝑣, 𝑤 carefully reduces the work. Def: A legal ordering of 𝐺 is an ordering 𝑣1, 𝑣2, …, 𝑣𝑛 of the nodes of 𝐺 such that, where 𝑉 𝑖 denotes {𝑣1, …, 𝑣 𝑖 } 𝑢 𝛿 𝑉 𝑖−1 ∩𝛿 𝑣 𝑖 ≥𝑢 𝛿 𝑉 𝑖−1 ∩𝛿 𝑣 𝑗 for 2≤𝑖<𝑗≤𝑛 Choose any node as 𝑣1 and at step 𝑖 choose 𝑣𝑖 that has the largest total capacity of edges joining it to the previously chosen nodes. Can be found in 𝑂(𝑛2) (refer Prim’s or Dijkstra’s algorithm) Thm 3.36: If 𝑣1, 𝑣2, …, 𝑣𝑛 is a legal ordering of 𝐺, then (𝑣𝑛) is a minimum ( 𝑣 𝑛 , 𝑣 𝑛−1 )-cut of 𝐺. Combinatorial Optimization 2016

Legal ordering beginning with a is : a, b, c, d, e, h, g, f 3 5 c a 2 2 4 3 h 1 d 3 e 2 2 5 6 g f Combinatorial Optimization 2016

Node Identification Minimum Cut Algorithm Initialize 𝑀 to be ∞, 𝐴 to be undefined While 𝐺 has more than one node Find a legal ordering 𝑣1, 𝑣2, …, 𝑣𝑛 of 𝐺; If 𝑢((𝑣𝑛))<𝑀 Replace 𝑀 by 𝑢((𝑣𝑛)), 𝐴 by (𝑣𝑛); Replace 𝐺 by 𝐺 𝑣 𝑛−1 𝑣 𝑛 ; Return 𝐴. Combinatorial Optimization 2016

(𝐺;𝑝, 𝑞)≥ min ((𝐺;𝑟, 𝑞), (𝐺;𝑝, 𝑟)) In proving the theorem, we do not assume 𝐺 is connected. (“Legal ordering” does not assume this) Lemma 3.37: If 𝑝, 𝑞, 𝑟∈𝑉, then (𝐺;𝑝, 𝑞)≥ min ((𝐺;𝑟, 𝑞), (𝐺;𝑝, 𝑟)) (pf) Choose a min (𝑝, 𝑞)-cut (𝑆) with 𝑝∈𝑆. If 𝑟∈𝑆, then (𝑆) is an (𝑟, 𝑞)-cut so 𝑢((𝑆))≥(𝐺;𝑞, 𝑟). Otherwise, (𝑆) is a (𝑝, 𝑟)-cut, so 𝑢((𝑆))≥(𝐺;𝑝, 𝑟).  Combinatorial Optimization 2016

(1) Let 𝐺′ denote 𝐺 with edge 𝑒 deleted. Then 𝑣1, …, 𝑣𝑛 still legal (Proof of Thm 3.36) Need to show 𝑢((𝑣𝑛))≤(𝐺; 𝑣 𝑛−1 , 𝑣 𝑛 ). Use induction on the number of edges and nodes. (trivial if |𝑉|=2 or |𝐸|=0) Consider two cases: (1) 𝑣 𝑛 𝑣 𝑛−1 is an edge 𝑒 of 𝐺 (2) 𝑣 𝑛 , 𝑣 𝑛−1 not adjacent in 𝐺. (1) Let 𝐺′ denote 𝐺 with edge 𝑒 deleted. Then 𝑣1, …, 𝑣𝑛 still legal ordering of 𝐺′ 𝑢((𝑣𝑛))=𝑢(′(𝑣𝑛))+𝑢𝑒=( 𝐺 ′ ; 𝑣 𝑛−1 , 𝑣 𝑛 )+𝑢𝑒=(𝐺; 𝑣 𝑛−1 , 𝑣 𝑛 ) (2) In this case, (𝑣𝑛) is a ( 𝑣 𝑛 , 𝑣 𝑛−1 )-cut, need to show that it is min ( 𝑣 𝑛 , 𝑣 𝑛−1 )-cut. From lemma 3.37, enough to show that 𝑢((𝑣𝑛))≤(𝐺; 𝑣 𝑛−2 , 𝑣 𝑛 ) and 𝑢((𝑣𝑛))≤(𝐺; 𝑣 𝑛−2 , 𝑣 𝑛−1 ) For the first case, apply induction on 𝐺′=𝐺∖ 𝑣 𝑛−1 . 𝑣1, .. , 𝑣 𝑛−2 , 𝑣𝑛 is a legal ordering of 𝐺′. Hence 𝑢((𝑣𝑛))=𝑢(′(𝑣𝑛))=( 𝐺 ′ ; 𝑣 𝑛−2 , 𝑣 𝑛 )≤(𝐺; 𝑣 𝑛−2 , 𝑣 𝑛 ) For the second case, apply induction on 𝐺′=𝐺∖𝑣𝑛 𝑣1, .. , 𝑣 𝑛−1 is a legal ordering of 𝐺′. Hence 𝑢((𝑣𝑛))≤𝑢(( 𝑣 𝑛−1 ))=𝑢(′( 𝑣 𝑛−1 ))=( 𝐺 ′ ; 𝑣 𝑛−2 , 𝑣 𝑛−1 )≤(𝐺; 𝑣 𝑛−2 , 𝑣 𝑛−1 )  Combinatorial Optimization 2016

Random Contraction Algorithm randomized algorithm for minimum cut problem Random Contraction Algorithm While 𝐺 has more than two nodes Choose an edge 𝑒 of 𝐺 with probability 𝑢𝑒/𝑢(𝐸); Where 𝑒=𝑣𝑤, replace 𝐺 by 𝐺𝑣𝑤 (edge contraction); Return 𝐴, the unique cut of 𝐺. Combinatorial Optimization 2016

Then the probability that an edge from 𝐴 is chosen at step 𝑖+1 is Thm 3.38: Let 𝐴 be a minimum cut of 𝐺. Then the random contraction algorithm returns 𝐴 with probability at least 2/𝑛(𝑛−1). (pf) Algorithm will return 𝐴 provided that none of its edges is chosen to be contracted. (some edges might be lost even though not contracted, but it causes no problem) Suppose 𝑖 edges have been chosen, none from 𝐴. Let the current graph be 𝐺′=(𝑉′, 𝐸′), with 𝑉 ′ =𝑛−𝑖. Since 𝐴 is min cut of 𝐺′, its capacity is at most the average of capacities 𝑢(′(𝑣)), 𝑣∈𝑉′ ( 𝑢(𝐴)≤𝑢(′(𝑣)) ). Thus, 𝑢(𝐴)≤2𝑢(𝐸′)/(𝑛−𝑖). Then the probability that an edge from 𝐴 is chosen at step 𝑖+1 is 𝑢(𝐴)/𝑢(𝐸′)≤2𝑢(𝐸′)/(𝑛−𝑖)𝑢(𝐸′)=2/(𝑛−𝑖) ⇒ The probability that no edge of 𝐴 is chosen at step 𝑖+1 is at least 1−2/(𝑛−𝑖)=(𝑛−𝑖−2) / (𝑛−𝑖), so the probability that no edge of 𝐴 is ever chosen is at least 𝑛−2 𝑛 ⋅ 𝑛−3 𝑛−1 ⋅ 𝑛−4 𝑛−2 ⋅⋅⋅ 3 5 ⋅ 2 4 ⋅ 1 3 = 2 𝑛(𝑛−1) .  Combinatorial Optimization 2016

Cor 3.39: Let 𝐴 be a minimum cut of 𝐺 and let 𝑘 be a positive integer. The probability that the random contraction algorithm does not return 𝐴 in one of 𝑘𝑛2 runs is at most 𝑒 −2𝑘 . (pf) By thm 3.38, the probability is at most 1− 2 𝑛(𝑛−1) 𝑘 𝑛 2 ≤ 1− 2 𝑛 2 𝑘 𝑛 2 ≤ 𝑒 − 2 𝑛 2 𝑘 𝑛 2 = 𝑒 −2𝑘 (since 1−𝑥≤ 𝑒 −𝑥 ) ex: run the algorithm for 10𝑛2 times : ( 1− 𝑒 −20 )≥0.99999999 Reference: Randomized Algorithms, Rajeev Motwani and Prabhakar Raghavan, Cambridge, 1995 Combinatorial Optimization 2016

3.5.2 Cut-Trees Multiterminal Cut Problem: Given an undirected graph 𝐺=(𝑉, 𝐸), 𝑢𝑒≥0 for all 𝑒∈𝐸, and a set of terminals 𝐾⊆𝑉, find a minimum (𝑟, 𝑠)-cut for each pair of nodes 𝑟, 𝑠∈𝐾. Procedure: Choose some pair of terminal nodes 𝑟, 𝑠∈𝐾. Find min (𝑟, 𝑠)-cut and denotes the two node sets in each side of the cut as 𝑅 and 𝑆. 𝑅 𝑃 𝑆 𝑆 p 𝑓(𝑟,𝑠) 𝑓(𝑝,𝑞) 𝑓(𝑟,𝑠) q 𝑄 Combinatorial Optimization 2016

General Procedure B3 B3 B2 B1 C1 B2 B1 C1 f(y,z) A Y Z E2 E1 D1 E2 E1 Combinatorial Optimization 2016

Tree satisfying the first property: K-flow-equivalent to 𝐺. Thm 3.40: For any 𝑟, 𝑠∈𝐾, the capacity of min (𝑟, 𝑠)-cut equals the minimum label 𝑓𝑒 in the (𝑟, 𝑠)-path in tree 𝑇. Moreover, min (𝑟, 𝑠)-cut is obtained by the bipartition of the tree obtained after eliminating the minimum weight edge 𝑒 ∗ from 𝑇. Tree satisfying the first property: K-flow-equivalent to 𝐺. Tree that also satisfies the second property : Gomory-Hu K-cut-tree ( Gomory-Hu cut-tree) Combinatorial Optimization 2016

Remarks Def: Let 𝑁 be a finite set, and let 𝑓 be a real-valued function on the subsets of 𝑁. Then 𝑓 is called submodular if 𝑓 𝑆 +𝑓 𝑇 ≥𝑓 𝑆∪𝑇 +𝑓(𝑆∩𝑇) for 𝑆,𝑇⊆𝑁. Prop: 𝑓 is submodular if and only if 𝑓 𝑆⋃ 𝑗 −𝑓 𝑆 ≥𝑓 𝑆∪ 𝑗,𝑘 −𝑓(𝑆∪ 𝑘 ), for 𝑗,𝑘∈𝑁, 𝑗≠𝑘, and 𝑆⊆𝑁∖ 𝑗,𝑘 . (function of diminishing marginal returns) Cut function of a graph (also for directed graph), matroid rank function (no details here), etc are examples of submodular functions. Combinatorial Optimization 2016

(pf) Let (𝑋) be a min (𝑣, 𝑤)-cut. May assume that 𝑠∈𝑋. Lemma 3.41: Let (𝑆) be a minimum (𝑟, 𝑠)-cut for some node 𝑟, 𝑠∈𝑉, and let 𝑣, 𝑤∈𝑆. Then there exists a minimum (𝑣, 𝑤)-cut (𝑇) such that 𝑇⊂𝑆. (pf) Let (𝑋) be a min (𝑣, 𝑤)-cut. May assume that 𝑠∈𝑋. Consider 2 cases: (1) 𝑟∈𝑋 (2) 𝑟∈𝑉\X (1) From submodular inequality (Exercise 3.66), we have 𝑢((𝑆∩(𝑉\X)))+𝑢((𝑆∪(𝑉\X)))≤𝑢((𝑆))+𝑢((𝑉\X)) Now 𝑢((𝑆∪(𝑉\X)))≥𝑢((𝑆)) since (𝑆∪(𝑉\X)) is an (𝑟, 𝑠)-cut ⇒ 𝑢((𝑆∩(𝑉\X)))≤𝑢((𝑉\X))=𝑢((𝑋)) So (𝑆∩(𝑉\X)) is a min (𝑣, 𝑤)-cut. Similarly for (2), can show (𝑆∩X) is a min (𝑣, 𝑤)-cut.  S w (2) r (1) r s v X Combinatorial Optimization 2016

(pf) True for the initial two node tree. Let 𝑇 be a tree produced at some stage of Gomory-Hu procedure and 𝑒 is an edge joining the sets(identified nodes) 𝑅 and 𝑆. We say that terminal nodes 𝑟∈𝑅 and 𝑠∈𝑆 are representatives for 𝑒 if 𝑓𝑒=𝑓(𝑟,𝑠). Lemma 3.42: At every stage of the Gomory-Hu procedure, there exists representatives for each edge of the tree 𝑇 (pf) True for the initial two node tree. Suppose we split a node 𝐴 into 𝑋 and 𝑌, based on an (𝑥, 𝑦)-cut. (𝑥∈𝑋, 𝑦∈𝑌) 𝑥 and 𝑦 are representatives for the edge joining 𝑋 and 𝑌 and other edges, except the ones incident to 𝐴 earlier, are not affected. Suppose 𝐵 is a node joined to 𝐴 (using edge ℎ) before the iteration is executed and assume 𝐵 is joined to node 𝑋 in the new tree. Then there exist 𝑎∈𝐴, 𝑏∈𝐵 which are representatives for ℎ such that 𝑓ℎ=𝑓(𝑎, 𝑏). Now consider 2 cases: (1) 𝑎∈𝑋 (2) 𝑎∈𝑌. (1): 𝑎 and 𝑏 continue to be representatives for ℎ. (2): can show that 𝑥 and 𝑏 are representatives for ℎ in the new tree.  Combinatorial Optimization 2016

b a B y B h Y h A a x X Proof of Lemma 3.42 Combinatorial Optimization 2016

Hence, the second assertion follows from the first. Thm 3.40: For any 𝑟, 𝑠∈𝐾, the capacity of min (𝑟, 𝑠)-cut equals the minimum label 𝑓 𝑒 in the (𝑟, 𝑠)-path in tree 𝑇. Moreover, min (𝑟, 𝑠)-cut is obtained by the bipartition of the tree obtained after eliminating the minimum weight edge 𝑒 ∗ from 𝑇. (Proof of Theorem 3.40) By construction of 𝑇, each edge 𝑒 in 𝑇 corresponds to a cut in 𝐺 specified by the bipartition of 𝑉 obtained by deleting 𝑒 from 𝑇, and this cut has capacity 𝑓𝑒. Hence, the second assertion follows from the first. Let 𝑉0, 𝑒1, 𝑉1, …, 𝑒𝑘, 𝑉𝑘 be the path that joins 𝑟 and 𝑠. Then 𝑓(𝑟, 𝑠)≤ min ( 𝑓 𝑒 1 ,…, 𝑓 𝑒 𝑘 ) since each of the cuts corresponding to the edges 𝑒1, …, 𝑒𝑘 separates 𝑟 and 𝑠. Let 𝑣𝑖 be the unique terminal node in 𝑉𝑖 for 𝑖=0, 1, …, 𝑘. Have 𝑣0=𝑟, 𝑣𝑘=𝑠. By Lemma 3.42, 𝑓 𝑒 𝑖 =𝑓( 𝑣 𝑖−1 , 𝑣 𝑖 ), for 𝑖=1, …, 𝑘 By Exercise 3.69, 𝑓(𝑟, 𝑠)≥ min ( 𝑓 𝑒 1 ,…, 𝑓 𝑒 𝑘 ) (𝑓( 𝑣 0 , 𝑣 𝑘 )≥𝑚𝑖𝑛𝑖𝑚𝑢𝑚(𝑓 𝑣 0 , 𝑣 1 ,𝑓 𝑣 1 , 𝑣 2 ,…,𝑓 𝑣 𝑘−1 , 𝑣 𝑘 ) for any choice of nodes 𝑣 0 , 𝑣 1 ,…, 𝑣 𝑘 ) ⇒ 𝑓(𝑟, 𝑠)= min ( 𝑓 𝑒 1 ,…, 𝑓 𝑒 𝑘 )  Combinatorial Optimization 2016

A variant of Gomory-Hu procedure can be used to identify the violated odd set constraint for the matching problem (Ref: M. W. Padberg and M. R. Rao (1982), Odd Minimum Cut-Sets and b-Matchings, Mathematics of Operations Research 7, 67-80.) More efficient implementation: D. Gusfield, "Very simple methods for all pairs network flow analysis," SIAM Journal on Computing 19 (1990) 143-155 Combinatorial Optimization 2016