Skip to content

Add IPM-based maximum flow solver (Chen et al. 2022)#18

Open
kenkoooo wants to merge 2 commits intomasterfrom
chen-ipm-max-flow
Open

Add IPM-based maximum flow solver (Chen et al. 2022)#18
kenkoooo wants to merge 2 commits intomasterfrom
chen-ipm-max-flow

Conversation

@kenkoooo
Copy link
Owner

Summary

  • Implement an interior point method (IPM) based maximum flow algorithm inspired by Chen, Kyng, Liu, Peng, Gutenberg, Sachdeva (2022) "Maximum Flow and Minimum-Cost Flow in Almost-Linear Time"
  • Reduces max flow to min-cost circulation, then solves with a primal-dual IPM using weighted Laplacian Newton steps
  • Modular design with 7 components, each independently unit-tested (23 tests total including GRL_6_A integration)

Algorithm components

  1. solve_laplacian — Gaussian elimination for weighted Laplacian systems
  2. prune_dead_ends — Iterative removal of edges to/from dead-end nodes
  3. compute_excess — Flow conservation violation at each node
  4. compute_step_size — Line search keeping flow strictly interior
  5. initialize_flow — Weighted projection of cap/2 onto conservation constraints
  6. ipm_step — Newton step via KKT conditions of barrier-penalized circulation
  7. max_flow — Integration: reduction → pruning → initialization → IPM loop → rounding

Test plan

  • Unit tests for Laplacian solver (path, triangle, weighted, single node)
  • Unit tests for dead-end pruning (cycle, dead-end, cascading, all dead)
  • Unit tests for excess computation
  • Unit tests for step size bounds
  • Unit tests for flow initialization (conservation + interiority)
  • Unit tests for IPM step (feasibility, positive alpha, convergence)
  • Integration tests (simple, no path, single edge)
  • GRL_6_A: all 40 test cases pass

🤖 Generated with Claude Code

kenkoooo and others added 2 commits March 19, 2026 02:14
Implement an interior point method approach to maximum flow, reducing
the problem to min-cost circulation and solving with a primal-dual
IPM using weighted Laplacian Newton steps. Includes 23 unit tests
covering each component (Laplacian solver, dead-end pruning, flow
initialization, IPM step, step size computation) plus GRL_6_A
integration tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace vec-of-vec with flat array in solve_laplacian to avoid
  per-call heap allocations (nn separate vectors → single flat buffer)
- Use adaptive barrier reduction based on step quality (alpha > 0.8
  → aggressive, alpha < 0.3 → conservative) instead of fixed shrink
- Reduce target_mu from 1e-9 to 1e-7 (sufficient for integer rounding)
- GRL_6_A test time: 6.1s → 0.46s (13x speedup)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant