Metadata-Version: 2.4
Name: pylmcf
Version: 0.9.1
Summary: Python bindings for Network Simplex algorithm from LEMON library
Keywords: network simplex,minimum cost flow,lemon,graph algorithms
Author-Email: =?utf-8?q?Micha=C5=82_Startek?= <michal.startek@mimuw.edu.pl>
Maintainer-Email: =?utf-8?q?Micha=C5=82_Startek?= <michal.startek@mimuw.edu.pl>
License-Expression: BSL-1.0
License-File: LICENCE
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Development Status :: 4 - Beta
Project-URL: Homepage, https://github.com/michalsta/pylmcf
Project-URL: Repository, https://github.com/michalsta/pylmcf.git
Requires-Dist: numpy
Provides-Extra: extras
Requires-Dist: networkx; extra == "extras"
Requires-Dist: matplotlib; extra == "extras"
Description-Content-Type: text/markdown

## pylmcf: Python bindings for Min Cost Flow algorithm from LEMON graph library

### Overview

`pylmcf` provides Python bindings for the Min Cost Flow algorithm implemented in the [LEMON graph library](https://lemon.cs.elte.hu/trac/lemon). It enables efficient network flow optimization in Python applications.

### Features

- Fast min cost flow computation using C++ backend
- Easy-to-use Python API
- Supports directed graphs, capacities, costs, and supplies/demands

### Installation

```bash
pip install git+https://github.com/michalsta/pylmcf.git
```

### Usage

```python
import numpy as np
import pylmcf

# Create a graph with 3 nodes, labelled 0, 1, 2, and edges 0->1, 0->2, 1->2
no_nodes = 3
node_supply = np.array([5, 0, -5])

edge_starts     = np.array([0, 0, 1])
edge_ends       = np.array([1, 2, 2])
edge_costs      = np.array([1, 3, 5])
edge_capacities = np.array([1, 2, 3])

G = pylmcf.Graph(3, edge_starts, edge_ends)
G.set_node_supply(node_supply)
G.set_edge_costs(edge_costs)
G.set_edge_capacities(edge_capacities)

G.show()

# Run the Min Cost Flow algorithm
G.solve()

# Retrieve the flow values
assert all(G.result() == np.array([1, 2, 1]))

# Retrieve the total cost of the flow
assert G.total_cost() == 12

```

### Requirements

- Python 3.7+

### Licence

pylmcf is published under Boost licence.
LEMON (which resides in src/pylmcf/cpp/lemon subdirectory) is also covered by Boost licence.

### References

- [LEMON Graph Library](https://lemon.cs.elte.hu/trac/lemon)
- [Min Cost Flow Problem](https://en.wikipedia.org/wiki/Minimum-cost_flow_problem)