OtterZ's blog

By OtterZ, 6 months ago, In English

Introduction

The max-flow min-cut theorem is a cornerstone of combinatorial optimization, providing a powerful framework for modeling a wide range of problems. While algorithms like Dinic’s are standard for computing maximum flows, their time complexity—often bounded by $$$\operatorname{O}({|V|}^2|E|)$$$ or $$$\operatorname{O}(|E|\sqrt{|E|})$$$ can become prohibitive for large-scale or specially structured graphs.

This article explores an alternative strategy: instead of applying a generic flow algorithm, we directly analyze the min-cut formulation. The min-cut problem seeks the minimum total capacity of edges whose removal disconnects the source $$$s$$$ from the sink $$$t$$$. Formally, this is expressed as:

$$$ \min_{P,s\in P\land t\notin P}\{\sum_{u\in P,v\notin P}C(u,v)\} $$$

By reformulating this combinatorial problem as a mathematical optimization task, we can often exploit the specific structure of the graph to derive highly efficient, custom-tailored solutions. This approach transforms a graph algorithm problem into a mathematical one, which can be significantly faster for certain problem classes.

Examples

ABC332G

At first I'd like to say ABC332G is the task that made me think if I can solve mincut problems in this way.

In the task we make a graph for example $$$1$$$ like this,and similar for others:

we are tasked with a distribution problem that can be modeled as a min-cut. The constraints are too large for a direct application of Dinic’s algorithm, necessitating a more analytical approach.So we try to use maths and get($$$SETA$$$ for the nodes that represents balls and $$$SETB$$$ for boxes,$$$u_i$$$ as node for $$$i$$$-th colour,$$$v_i$$$ for $$$i$$$-th box):

$$$ \begin{aligned} \operatorname{maxflow}(G) &= \operatorname{mincut}(G)\\ &= \min_P\{\sum_{u_i\in\complement_{V}P \cup SETA}A_i + sum_{v_i \in P\cup SETB}B_i + sum_{u_i\in P\cup SETA,v_j \in \complement_V P \cup SETB}{i \cdot j}\}\\ &= \min_P\{\sum_{u_i\in\complement_{V}P \cup SETA}A_i + sum_j \min\{B_j,sum_{u_i\in P\cup SETA}{i \cdot j}\}\}\\

&= \min_k\{\min_{P,\sum_{u_i \in P} i = k}\{\sum_{u_i\in\complement_{V}P \cup SETA}A_i\} + sum_j \min\{B_j,k \cdot j\}\}\\ \end{aligned} $$$

As

$$$\sum_j \min\{B_j,k \cdot j\}$$$

can be calculated using prefix sum,and

$$$\min_{P,\sum_{u_i \in P} i = k}\{\sum_{u_i\in\complement_{V}P \cup SETA}A_i\}$$$

can be calculated using dynamic planning,so the task is then solved in $$$\operatorname{O}(n^3 + m)$$$.

code

2.ARC125E

For ARC125E,the graph is constructed like this:

and found the task presents another scenario where a direct max-flow computation is infeasible due to large values of $$$N,M,A_i,B_i,C_i$$$, which we has to calculate the mincut:

$$$ \begin{aligned} \operatorname{maxflow}(G) &= \operatorname{mincut}(G)\\ &= \min_P\{\sum_{u_i\in\complement_{V}P \cup SETA}C_i + sum_{v_i \in P\cup SETB}A_i + sum_{u_i\in P\cup SETA,v_j \in \complement_V P \cup SETB}{B_i}\}\\ &= \min_P\{\sum_{u_i\in\complement_{V}P \cup SETA}C_i + sum_j \min\{A_j,sum_{u_i\in P\cup SETA}{B_i}\}\}\\

&= \min_k\{\min_{P,\sum_{u_i \in P} B_i = k}\{\sum_{u_i\in\complement_{V}P \cup SETA}C_i\} + sum_j \min\{A_j,k\}\}\\ \end{aligned} $$$

There,

$$$\operatorname{F}(x) = \sum_j\{\min \{A_j,x\} \}$$$

can be deem as an convex function that can be calculated using prefix sums and binary search in $$$\operatorname{O}(n) - \operatorname{O}(\log n)$$$,and

$$$\operatorname{G}(x) = \operatorname{F}(\sum B_i) -\operatorname{F}(\sum B_i — x)$$$

is an lower convex function. And for

$$$\operatorname{H}(k) = \min_{P,\sum_{u_i \in P} B_i = k}\{\sum_{u_i\in\complement_{V}P \cup SETA}C_i\}$$$

,it's proven that we can just calculate

$$$\operatorname{H}(k) + \operatorname{F}(\sum B_i — k)$$$

just on the turning point of the low convex by adjustment.

prove

At last,the convex can be found by sorting the children in a non-decreasing order of $$$\frac{C_i}{B_i}$$$ and adding up the children one by one and solve the task in $$$\operatorname{O}(n\log n)$$$.

code

CF903G

In 903G - Yet Another Maxflow Problem, we are asked to compute a max-flow value in a dynamic graph. Again, a direct flow algorithm is too slow, but the min-cut formulation reveals a tractable mathematical structure:

$$$ min_{i,j}\{A_i + B_j + \sum_{x_k \le i,y_k \ge j}z_k\} = min_i \{a_i + min_j\{B_j + \sum_{x_k \le i,y_k \ge j}z_k\}\} $$$

The $$$j$$$ for getting the $$$\min{B_j + \sum_{x_k \le i,y_k \ge j}z_k}$$$ of each $$$i$$$ is non-decreasing,making it solvable using divide and consequer in $$$\operatorname{O}(n\log^2n)$$$,then for furthur things,we use segment tree and solve it easily.

code

At last

  • Vote: I like it
  • +80
  • Vote: I do not like it

»
6 months ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

Auto comment: topic has been updated by OtterZ (previous revision, new revision, compare).

»
4 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Could anyone put this blog into catalog?