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.fixUpdate 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.fixCompare 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.fixEnsure 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.fixVerify `sum(supply) == 0`.
affects: all
gotchaEdge lower bounds must be <= upper bounds; violation causes undefined behavior.fixCheck 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)