# ã¯ã©ã¹ MaxFlow
## ã³ã³ã¹ãã©ã¯ã¿
```java
public MaxFlow(int n)
```
`n` é ç¹ `0` 辺ã®ã°ã©ããä½ãã
è¨ç®é
$O(n)$
## ã¡ã½ãã
### addEdge
```java
public void addEdge(int from, int to, long cap)
```
`from` ãã `to` ã¸æå¤§å®¹é `cap`ãæµé 0 ã®è¾ºã追å ããä½çªç®ã«è¿½å ããã辺ããè¿ãã
å¶ç´
- `0 <= from, to < n`
- `0 <= cap`
è¨ç®é
ãªãã $O(1)$
### maxFlow
```java
// (1)
public long maxFlow(int s, int t)
// (2)
public long flow(int s, int t, long flowLimit)
// (3)
public long fordFulkersonMaxFlow(int s, int t)
// (4)
public long fordFulkersonFlow(int s, int t, long flowLimit)
```
- (1): é ç¹ `s` ãã `t` ã¸æµããéãæµããæµããéãè¿ããDinic ã®ã¢ã«ã´ã«ãºã ãç¨ãã¾ãã
- (2) é ç¹ `s` ãã `t` ã¸æµé `flowLimit` ã«éããã¾ã§æµããéãæµããæµããéãè¿ããDinic ã®ã¢ã«ã´ã«ãºã ãç¨ãã¾ãã
- (3) é ç¹ `s` ãã `t` ã¸æµããéãæµããæµããéãè¿ããFordFulkerson ã®ã¢ã«ã´ã«ãºã ãç¨ãã¾ãã
- (4) é ç¹ `s` ãã `t` ã¸æµé `flowLimit` ã«éããã¾ã§æµããéãæµããæµããéãè¿ããFordFulkerson ã®ã¢ã«ã´ã«ãºã ãç¨ãã¾ãã
- è¤æ°åå¼ãã å ´åã¯ï¼ååæµããããã¼ããã®å·®åãè¿ãã¾ãã
å¶ç´
- `0 <= s, t < n`
è¨ç®é
`m` ã追å ããã辺æ°ã¨ãã¦
- (1), (2) $O(\min(n^{2/3}*m, m^{3/2}))$ (辺ã®å®¹éããã¹ã¦ 1 ã®æ)
- (1), (2) $O(n^2*m)$
- (3), (4) è¿ãå¤ã `f` ã¨ãã¦ï¼`O(f*m)`
### minCut
```java
public boolean[] minCut(int s)
```
é·ã `n` ã® `boolean` é
åãè¿ãã`i` çªç®ã®è¦ç´ ã¯ãé ç¹ `s` ãã `i` ã¸æ®ä½ã°ã©ãã§å°éå¯è½ãªã¨ããã¾ããã®æã®ã¿ `true`ãmaxFlow(s, t) ãã¡ããã©ä¸åå¼ãã å¾ã«å¼ã¶ã¨ãè¿ãå¤ã¯ `s`, `t` éã® mincut ã«å¯¾å¿ãã¾ãã
è¨ç®é
`m` ã追å ããã辺æ°ã¨ã㦠$O(n+m)$
### getEdge / getEdges
`getEdge`ã`getEdges` ã®è¿ãå¤ã«ã¯ä»¥ä¸ã®ã¡ã½ãããæã¤ `MaxFlow.CapEdge` åãç¨ãããã¦ãã¾ãã
```java
class CapEdge {
// (1)
public int getFrom()
// (2)
public int getTo()
// (3)
public long getCap()
// (4)
public long getFlow()
};
```
- (1): å§ç¹ãè¿ãã¾ããè¨ç®é: $O(1)$
- (2): çµç¹ãè¿ãã¾ããè¨ç®é: $O(1)$
- (3): ç¾å¨ã®å®¹éãè¿ãã¾ããè¨ç®é: $O(1)$
- (4): ç¾å¨ã®æµéãè¿ãã¾ããè¨ç®é: $O(1)$
```java
// (1)
public CapEdge getEdge(int i)
// (2)
public java.util.ArrayList