Registry / analytics / pylmcf

pylmcf

JSON →
library0.9.13pypypi✓ verified 84d ago

Python bindings for the Network Simplex algorithm from the LEMON library, providing minimum cost flow (MCF) solvers for directed graphs. Version 0.9.13, mature but stable with infrequent releases.

pip install pylmcf
INSTALL
IMPORT
SIG · PYLMCF
P
pylmcf
analyticspythonv0.9.13
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Graph
✓ from pylmcf import Graph
✗ from pylmcf import MinCostFlow
graph
✓ from pylmcf import graph
pylmcf_cpp
✓ from pylmcf import pylmcf_cpp

Build a graph with supply/demand and solve minimum cost flow.

import os from pylmcf import MinCostFlow # Simple supply-demand flow n = 4 # nodes edges = [(0,1,0,5,2), (0,2,0,3,1), (1,3,0,4,3), (2,3,0,2,4)] # (from, to, lower, upper, cost) supply = [3, 0, 0, -3] # node supplies (demand negative) mcf = MinCostFlow() mcf.build(n, edges, supply) result = mcf.solve() print("Feasible:", result == mcf.FEASIBLE) print("Total cost:", mcf.get_cost()) flow = [mcf.get_flow(i) for i in range(len(edges))] print("Edge flows:", flow)
Debug
Known issues
breakingIn version 0.9.10, the `build()` method signature changed; `node_num` argument is now positional and `edges` format must include lower bound.
fix
Update to use `mcf.build(n, edges, supply)` where edges are tuples (from, to, lower, upper, cost).
affects: <0.9.10 -> >=0.9.10
breaking`solve()` return values changed: now returns integer constants (e.g., 0 for FEASIBLE, 1 for INFEASIBLE, 2 for UNBOUNDED) instead of boolean.
fix
Compare result to `mcf.FEASIBLE` or `mcf.INFEASIBLE`, not `True/False`.
affects: <0.9.10 -> >=0.9.10
gotchaNode numbering must be contiguous integers starting from 0; gaps cause silent errors or crashes.
fix
Ensure nodes are numbered 0..n-1 without skipping indices.
affects: all
gotchaSupply/demand arrays must sum to zero; otherwise the solver may hang or return UNBOUNDED.
fix
Verify `sum(supply) == 0`.
affects: all
gotchaEdge lower bounds must be <= upper bounds; violation causes undefined behavior.
fix
Check that lower <= upper for each edge.
affects: all
Upgrade
Version history
0.9.13latest on PyPI · released May 19, 2026
Audit
Dependencies
lemonrequiredCore algorithm (C++ library, bundled with pylmcf)
Agent activity
23 hits · last 30 days
node
22
OpenAI (training)
1
Resources
pylmcf — pip install pylmcf · libregistry