diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index ebf3220..6b33f71 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: - os: [macos-latest, windows-latest] + os: [macos-latest] name: Build with ${{ matrix.os }} diff --git a/README.md b/README.md index f47ca47..4e17421 100644 --- a/README.md +++ b/README.md @@ -7,16 +7,44 @@ 使用 `Dinic` 和朴素费用流,算法来自 [DuckKnowNothing - 网络流](https://github.com/UPCACM/DuckKnowNothing/tree/master/src/GraphAlgorithm/%E7%BD%91%E7%BB%9C%E6%B5%81) -## 使用指南 +## 支持平台 + +> 在尝试了各种方法之后,GitHub Actions 在 Windows 平台下始终无法正确编译 C++,所以放弃支持 Windows 平台 + ++ Linux ++ macOS + +## 安装 ```bash pip install flow-network ``` -[样例代码](https://github.com/LucienShui/flow-network/blob/main/tests.py) +## 样例代码 + +```python +from flow_network import FlowNetwork, MinimumCostFlow + +fn = FlowNetwork(2) # 创建一个包含 2 个点的网络流对象,下标从 0 开始 +fn.add_edge(0, 1, 3) # 添加一条从 0 指向 1 的边,流量为 3 +result = fn.run(0, 1) # 指定源点为 0,汇点为 1,跑最大流 & 最小割 +print(result) # 3 + +mcf = MinimumCostFlow(2) # 创建一个包含 2 个点的费用流对象,下标从 1 开始 +mcf.add_edge(0, 1, 3, 2) # 添加一条从 0 指向 1 的边,流量为 3,单位流量的费用为 2 +flow, cost = mcf.run(0, 1) # 指定源点为 0,汇点为 1,跑最大流 & 最小费 +print(flow, cost) # 3 6 +``` + +### 测试代码 + +[tests.py](https://github.com/LucienShui/flow-network/blob/main/tests.py) ## Reference + [How to use C++ classes with ctypes?](https://stackoverflow.com/questions/1615813/how-to-use-c-classes-with-ctypes) + [Calling C/C++ from Python?](https://stackoverflow.com/questions/145270/calling-c-c-from-python) + [C Class Instance from Void Pointer using Ctypes](https://stackoverflow.com/questions/19389124/c-class-instance-from-void-pointer-using-ctypes) ++ [Python 库打包分发、setup.py 编写、混合 C 扩展打包的简易指南(转载)](https://www.cnblogs.com/xueweihan/p/12030457.html) ++ [Binary wheel can't be uploaded on pypi using twine](https://stackoverflow.com/questions/59451069/binary-wheel-cant-be-uploaded-on-pypi-using-twine) ++ [Manylinux wheel builder](https://github.com/Niraj-Kamdar/manylinux-wheel-builder) diff --git a/flow_network/__version__.py b/flow_network/__version__.py index b26735c..fc3a1ea 100644 --- a/flow_network/__version__.py +++ b/flow_network/__version__.py @@ -1,8 +1,8 @@ __title__ = 'flow-network' __description__ = 'Flow Network C++ Implementation' __url__ = 'https://github.com/LucienShui/flow-network' -__version__ = '0.1.1' -__build__ = 0x000101 +__version__ = '0.1.2' +__build__ = 0x000102 __author__ = 'Lucien Shui' __author_email__ = 'lucien@lucien.ink' __license__ = 'Apache 2.0'