Skip to content

Commit 306109f

Browse files
committed
Add graph flow and cut cards
1 parent ad53d9b commit 306109f

17 files changed

Lines changed: 844 additions & 0 deletions

assets/card-tags.json

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,15 @@
312312
],
313313
"title": "Adjacency Matrix"
314314
},
315+
"/cards/graphs/augmenting-path/": {
316+
"category": "graphs",
317+
"tags": [
318+
"graphs",
319+
"algorithms",
320+
"network-flow"
321+
],
322+
"title": "Augmenting Path"
323+
},
315324
"/cards/graphs/bellman-ford/": {
316325
"category": "graphs",
317326
"tags": [
@@ -373,6 +382,60 @@
373382
],
374383
"title": "Dijkstra's Algorithm"
375384
},
385+
"/cards/graphs/dinic/": {
386+
"category": "graphs",
387+
"tags": [
388+
"graphs",
389+
"algorithms",
390+
"network-flow"
391+
],
392+
"title": "Dinic's Algorithm"
393+
},
394+
"/cards/graphs/edge-cut-vs-vertex-cut/": {
395+
"category": "graphs",
396+
"tags": [
397+
"graphs",
398+
"graph-theory",
399+
"connectivity"
400+
],
401+
"title": "Edge Cut vs Vertex Cut"
402+
},
403+
"/cards/graphs/edmonds-karp/": {
404+
"category": "graphs",
405+
"tags": [
406+
"graphs",
407+
"algorithms",
408+
"network-flow"
409+
],
410+
"title": "Edmonds-Karp Algorithm"
411+
},
412+
"/cards/graphs/flow-network/": {
413+
"category": "graphs",
414+
"tags": [
415+
"graphs",
416+
"graph-theory",
417+
"network-flow"
418+
],
419+
"title": "Flow Network"
420+
},
421+
"/cards/graphs/ford-fulkerson/": {
422+
"category": "graphs",
423+
"tags": [
424+
"graphs",
425+
"algorithms",
426+
"network-flow"
427+
],
428+
"title": "Ford-Fulkerson Method"
429+
},
430+
"/cards/graphs/global-minimum-cut/": {
431+
"category": "graphs",
432+
"tags": [
433+
"graphs",
434+
"algorithms",
435+
"graph-theory"
436+
],
437+
"title": "Global Minimum Cut"
438+
},
376439
"/cards/graphs/graph-algorithms/": {
377440
"category": "graphs",
378441
"tags": [
@@ -390,6 +453,15 @@
390453
],
391454
"title": "Graph Fourier Transform"
392455
},
456+
"/cards/graphs/karger-min-cut/": {
457+
"category": "graphs",
458+
"tags": [
459+
"graphs",
460+
"algorithms",
461+
"randomized"
462+
],
463+
"title": "Karger's Algorithm (Min Cut)"
464+
},
393465
"/cards/graphs/kruskal/": {
394466
"category": "graphs",
395467
"tags": [
@@ -416,6 +488,26 @@
416488
],
417489
"title": "Graph Laplacian"
418490
},
491+
"/cards/graphs/max-flow-min-cut-theorem/": {
492+
"category": "graphs",
493+
"tags": [
494+
"graphs",
495+
"algorithms",
496+
"optimization",
497+
"network-flow"
498+
],
499+
"title": "Max-Flow Min-Cut Theorem"
500+
},
501+
"/cards/graphs/maximum-flow/": {
502+
"category": "graphs",
503+
"tags": [
504+
"graphs",
505+
"algorithms",
506+
"optimization",
507+
"network-flow"
508+
],
509+
"title": "Maximum Flow"
510+
},
419511
"/cards/graphs/message-passing/": {
420512
"category": "graphs",
421513
"tags": [
@@ -425,6 +517,16 @@
425517
],
426518
"title": "Message Passing (on Graphs)"
427519
},
520+
"/cards/graphs/minimum-cut/": {
521+
"category": "graphs",
522+
"tags": [
523+
"graphs",
524+
"algorithms",
525+
"optimization",
526+
"network-flow"
527+
],
528+
"title": "Minimum Cut"
529+
},
428530
"/cards/graphs/minimum-spanning-tree/": {
429531
"category": "graphs",
430532
"tags": [
@@ -468,6 +570,15 @@
468570
],
469571
"title": "Prim's Algorithm"
470572
},
573+
"/cards/graphs/residual-graph/": {
574+
"category": "graphs",
575+
"tags": [
576+
"graphs",
577+
"algorithms",
578+
"network-flow"
579+
],
580+
"title": "Residual Graph"
581+
},
471582
"/cards/graphs/shortest-path/": {
472583
"category": "graphs",
473584
"tags": [

assets/formulas.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@
215215
"route": "/cards/graphs/adjacency-matrix/",
216216
"formula_markdown": "\\[\nA_{ij} = \\begin{cases}1,& (i,j)\\in E\\\\0,&\\text{otherwise}\\end{cases}\n\\]"
217217
},
218+
{
219+
"title": "Augmenting Path",
220+
"category": "Graphs",
221+
"route": "/cards/graphs/augmenting-path/",
222+
"formula_markdown": "\\[\n\\Delta=\\min_{(u,v)\\in P} c_f(u,v)\n\\]"
223+
},
218224
{
219225
"title": "Bellman-Ford Algorithm",
220226
"category": "Graphs",
@@ -257,6 +263,42 @@
257263
"route": "/cards/graphs/dijkstra/",
258264
"formula_markdown": "\\[\nd(v) = \\min_{(u,v)\\in E}\\big(d(u)+w(u,v)\\big)\n\\]"
259265
},
266+
{
267+
"title": "Dinic's Algorithm",
268+
"category": "Graphs",
269+
"route": "/cards/graphs/dinic/",
270+
"formula_markdown": "\\[\n\\text{Repeat: build level graph via BFS, then send a blocking flow}\n\\]"
271+
},
272+
{
273+
"title": "Edge Cut vs Vertex Cut",
274+
"category": "Graphs",
275+
"route": "/cards/graphs/edge-cut-vs-vertex-cut/",
276+
"formula_markdown": "\\[\n\\lambda(G)=\\min |F| \\text{ over edge cuts }F,\\qquad\n\\kappa(G)=\\min |S| \\text{ over vertex cuts }S\n\\]"
277+
},
278+
{
279+
"title": "Edmonds-Karp Algorithm",
280+
"category": "Graphs",
281+
"route": "/cards/graphs/edmonds-karp/",
282+
"formula_markdown": "\\[\n\\text{Each augmentation uses a BFS shortest path (by edge count) in } G_f\n\\]"
283+
},
284+
{
285+
"title": "Flow Network",
286+
"category": "Graphs",
287+
"route": "/cards/graphs/flow-network/",
288+
"formula_markdown": "\\[\nG=(V,E),\\quad c:E\\to \\mathbb{R}_{\\ge 0},\\quad s,t\\in V\n\\]"
289+
},
290+
{
291+
"title": "Ford-Fulkerson Method",
292+
"category": "Graphs",
293+
"route": "/cards/graphs/ford-fulkerson/",
294+
"formula_markdown": "\\[\nf \\leftarrow f + \\Delta \\text{ along an augmenting path } P,\\quad\n\\Delta=\\min_{e\\in P} c_f(e)\n\\]"
295+
},
296+
{
297+
"title": "Global Minimum Cut",
298+
"category": "Graphs",
299+
"route": "/cards/graphs/global-minimum-cut/",
300+
"formula_markdown": "\\[\n\\lambda(G)=\\min_{\\varnothing\\ne S\\subset V,\\ S\\ne V} \\operatorname{cut}(S,V\\setminus S)\n\\]"
301+
},
260302
{
261303
"title": "Graph Algorithms (Overview)",
262304
"category": "Graphs",
@@ -269,6 +311,12 @@
269311
"route": "/cards/graphs/graph-fourier-transform/",
270312
"formula_markdown": "\\[\n\\hat{x} = U^\\top x\n\\quad\\text{and}\\quad\nx = U\\hat{x}\n\\]"
271313
},
314+
{
315+
"title": "Karger's Algorithm (Min Cut)",
316+
"category": "Graphs",
317+
"route": "/cards/graphs/karger-min-cut/",
318+
"formula_markdown": "\\[\n\\text{Repeat random edge contractions until 2 supernodes remain; return crossing edges}\n\\]"
319+
},
272320
{
273321
"title": "Kruskal's Algorithm",
274322
"category": "Graphs",
@@ -287,12 +335,30 @@
287335
"route": "/cards/graphs/laplacian/",
288336
"formula_markdown": "\\[\nL = D - A\n\\]"
289337
},
338+
{
339+
"title": "Max-Flow Min-Cut Theorem",
340+
"category": "Graphs",
341+
"route": "/cards/graphs/max-flow-min-cut-theorem/",
342+
"formula_markdown": "\\[\n\\max\\{\\text{value of an } s\\text{-}t \\text{ flow}\\}\n=\n\\min\\{\\text{capacity of an } s\\text{-}t \\text{ cut}\\}\n\\]"
343+
},
344+
{
345+
"title": "Maximum Flow",
346+
"category": "Graphs",
347+
"route": "/cards/graphs/maximum-flow/",
348+
"formula_markdown": "\\[\n\\max \\sum_{v} f(s,v)\n\\quad\\text{s.t.}\\quad\n0\\le f(u,v)\\le c(u,v),\\;\n\\sum_u f(u,v)=\\sum_w f(v,w)\\ \\ (v\\ne s,t)\n\\]"
349+
},
290350
{
291351
"title": "Message Passing (on Graphs)",
292352
"category": "Graphs",
293353
"route": "/cards/graphs/message-passing/",
294354
"formula_markdown": "\\[\nm_v^{(t+1)}=\\mathrm{AGG}\\big(\\{\\,\\phi(h_v^{(t)},h_u^{(t)},e_{uv}) : u\\in \\mathcal{N}(v)\\,\\}\\big)\n\\]\n\n\\[\nh_v^{(t+1)}=\\psi(h_v^{(t)}, m_v^{(t+1)})\n\\]"
295355
},
356+
{
357+
"title": "Minimum Cut",
358+
"category": "Graphs",
359+
"route": "/cards/graphs/minimum-cut/",
360+
"formula_markdown": "\\[\n\\operatorname{cut}(S,T)=\\sum_{u\\in S,\\ v\\in T} c(u,v),\\qquad\n(S^*,T^*)=\\arg\\min_{s\\in S,\\ t\\in T}\\operatorname{cut}(S,T)\n\\]"
361+
},
296362
{
297363
"title": "Minimum Spanning Tree (MST)",
298364
"category": "Graphs",
@@ -323,6 +389,12 @@
323389
"route": "/cards/graphs/prim/",
324390
"formula_markdown": "\\[\n\\text{Grow a tree by repeatedly adding the minimum-weight edge crossing the cut}\n\\]"
325391
},
392+
{
393+
"title": "Residual Graph",
394+
"category": "Graphs",
395+
"route": "/cards/graphs/residual-graph/",
396+
"formula_markdown": "\\[\nc_f(u,v)=c(u,v)-f(u,v),\\qquad\nc_f(v,u)=f(u,v)\n\\]"
397+
},
326398
{
327399
"title": "Shortest Path (Overview)",
328400
"category": "Graphs",

cards/graphs/augmenting-path.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
id: graph.augmenting-path
3+
title: Augmenting Path
4+
tags: [graphs, algorithms, network-flow]
5+
related: [graph.residual-graph, graph.ford-fulkerson, graph.edmonds-karp]
6+
prereqs: [graph.residual-graph]
7+
---
8+
9+
# Augmenting Path
10+
11+
<div class="formula" markdown="1">
12+
## Formula
13+
\[
14+
\Delta=\min_{(u,v)\in P} c_f(u,v)
15+
\]
16+
17+
</div>
18+
<div class="parameters" markdown="1">
19+
## Parameters
20+
- \(P\): \(s\)-to-\(t\) path in the residual graph
21+
- \(c_f(u,v)\): residual capacity on edge \((u,v)\)
22+
- \(\Delta\): bottleneck residual capacity on \(P\)
23+
24+
</div>
25+
## What it means
26+
An augmenting path is a path from source to sink in the residual graph along which additional flow can be pushed by the bottleneck amount \(\Delta\).
27+
28+
## What it's used for
29+
- Iterative improvement step in Ford-Fulkerson-style max-flow algorithms.
30+
- Constructive proof that flow is not yet maximal when such a path exists.
31+
32+
## Key properties
33+
- Augmenting by \(\Delta\) preserves feasibility.
34+
- If no augmenting path exists, the current flow is maximum.
35+
- Path selection strategy affects runtime substantially.
36+
37+
## Common gotchas
38+
- The path is found in the residual graph, not necessarily the original graph.
39+
- Some path choices can lead to poor performance in Ford-Fulkerson.
40+
- Bottleneck is the minimum residual capacity, not the sum.
41+
42+
## Example
43+
If a residual path has capacities \((5,3,9)\), you can augment by 3 units along that path.
44+
45+
## See also
46+
- [Residual Graph](../graphs/residual-graph.md)
47+
- [Ford-Fulkerson Method](../graphs/ford-fulkerson.md)
48+
- [Edmonds-Karp Algorithm](../graphs/edmonds-karp.md)

cards/graphs/dinic.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
id: graph.dinic
3+
title: Dinic's Algorithm
4+
tags: [graphs, algorithms, network-flow]
5+
related: [graph.maximum-flow, graph.edmonds-karp, graph.residual-graph]
6+
prereqs: [graph.maximum-flow, graph.residual-graph, graph.bfs]
7+
---
8+
9+
# Dinic's Algorithm
10+
11+
<div class="formula" markdown="1">
12+
## Formula
13+
\[
14+
\text{Repeat: build level graph via BFS, then send a blocking flow}
15+
\]
16+
17+
</div>
18+
<div class="parameters" markdown="1">
19+
## Parameters
20+
- Level graph: residual edges that advance one BFS layer
21+
- Blocking flow: flow that saturates every \(s\)-\(t\) path in the level graph
22+
- \(G_f\): residual graph
23+
24+
</div>
25+
## What it means
26+
Dinic accelerates max-flow by batching augmentations within layered residual graphs instead of using only one augmenting path per BFS.
27+
28+
## What it's used for
29+
- Faster max-flow computation in many practical graph problems.
30+
- Competitive programming and algorithmic graph toolkits.
31+
32+
## Key properties
33+
- Uses alternating BFS (levels) and DFS-style blocking-flow searches.
34+
- Improves over Edmonds-Karp in many settings.
35+
- Classical runtime bound is \(O(|V|^2|E|)\) in general networks.
36+
37+
## Common gotchas
38+
- Correct implementation needs current-edge pointers to avoid repeated scans.
39+
- "Blocking flow" is not necessarily a maximum flow in the level graph.
40+
- Residual updates must maintain reverse edges consistently.
41+
42+
## Example
43+
After BFS assigns levels, DFS pushes flow only along level-respecting edges until all \(s\)-\(t\) paths in that level graph are blocked.
44+
45+
## See also
46+
- [Maximum Flow](../graphs/maximum-flow.md)
47+
- [Edmonds-Karp Algorithm](../graphs/edmonds-karp.md)
48+
- [Residual Graph](../graphs/residual-graph.md)

0 commit comments

Comments
 (0)