Flow Network
网络流的工业级应用
使用 Dinic 和朴素费用流,算法来自 DuckKnowNothing - 网络流
支持平台
在尝试了各种方法之后,GitHub Actions 在 Windows 平台下始终无法正确编译 C++,所以放弃支持 Windows 平台
- Linux
- macOS
安装
pip install flow-network
样例代码
from flow_network import MaximumFlow, MinimumCostFlow
mf = MaximumFlow(2) # 创建一个包含 2 个点的网络流对象,下标从 0 开始
mf.add_edge(0, 1, 3) # 添加一条从 0 指向 1 的边,容量为 3
result = mf.run(0, 1) # 指定源点为 0,汇点为 1,跑最大流 & 最小割
print(result) # 3
for edge in mf.edges: # 遍历每条边
print(edge.u, edge.v, edge.flow, edge.capacity) # 边的起点、终点、流过的流量、最大容量
mcf = MinimumCostFlow(2) # 创建一个包含 2 个点的费用流对象,下标从 0 开始
mcf.add_edge(0, 1, 3, 2) # 添加一条从 0 指向 1 的边,容量为 3,单位流量的费用为 2
flow, cost = mcf.run(0, 1) # 指定源点为 0,汇点为 1,跑最大流 & 最小费
print(flow, cost) # 3 6
for edge in mcf.edges:
print(edge.u, edge.v, edge.flow, edge.capacity, edge.cost) # 边的起点、终点、流过的流量、最大容量、单位流量的费用
测试代码
Reference
Metadata
Release files for flow-network 0.1.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flow-network-0.1.13.tar.gz | 63.4 kB | Without provenance | Details for flow-network-0.1.13.tar.gz |
Built distributions (wheels)
Total release size: 5.4 MB
Release files / flow-network-0.1.13.tar.gz
| Download URL | flow-network-0.1.13.tar.gz |
|---|---|
| Size | 63.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a5ed54ae2dc2dff44d85ba3642ed535e5b3a7e12148556cd77426a336de980b
|
|
BLAKE2b-256 checksum How to use checksums |
7aa2521c51b8fa3d0e9d62f1bc5d04123137d84334f715a8708d5871b141c800
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
|
Release files / flow_network-0.1.13-cp39-cp39-manylinux2010_x86_64.whl
| Download URL | flow_network-0.1.13-cp39-cp39-manylinux2010_x86_64.whl |
|---|---|
| Size | 640.4 kB |
| Tags | CPython 3.9 Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
94dd1e8b73983bf4a6f7fb17e8cbd604e11cb1fbd9f0dae333a0f02fb6d122c2
|
|
BLAKE2b-256 checksum How to use checksums |
2763f8b466c947ca199c23e705526de24f0b87f0994539cd480c0cb03b5f1097
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
|
Release files / flow_network-0.1.13-cp39-cp39-manylinux1_x86_64.whl
| Download URL | flow_network-0.1.13-cp39-cp39-manylinux1_x86_64.whl |
|---|---|
| Size | 640.4 kB |
| Tags | CPython 3.9 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
55815d0632b3e74afb90b56e3dc502889a090f5e42d91201760f4629c03cdc5f
|
|
BLAKE2b-256 checksum How to use checksums |
82424456fd935958fc21566be8a5613e442e979613ec9639d21883b75b1745bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
|
Release files / flow_network-0.1.13-cp38-cp38-win_amd64.whl
| Download URL | flow_network-0.1.13-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 100.5 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
121f1b3434cef704ee0f61007a439dfe757b0bb131aab81cdc6bacf7b39acf47
|
|
BLAKE2b-256 checksum How to use checksums |
53d4eac679724aac131616a8fba06ac6b0e569a6aeca986028b6cbca271ca0b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
|
Release files / flow_network-0.1.13-cp38-cp38-manylinux2010_x86_64.whl
| Download URL | flow_network-0.1.13-cp38-cp38-manylinux2010_x86_64.whl |
|---|---|
| Size | 635.1 kB |
| Tags | CPython 3.8 Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
813e93a47aa4d1f7c231fce42b2a55a028b6e7b960f941b22f56fbfec61199bc
|
|
BLAKE2b-256 checksum How to use checksums |
ebbd0f92bca457210a359cb3b2cf36b72b7f0923c4bb0ae5c4a0a8166c297082
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
|
Release files / flow_network-0.1.13-cp38-cp38-manylinux1_x86_64.whl
| Download URL | flow_network-0.1.13-cp38-cp38-manylinux1_x86_64.whl |
|---|---|
| Size | 635.1 kB |
| Tags | CPython 3.8 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
ee4fe85bf7fa43019e17471e27b9358571111493746cb8bf6897f4484044ff8f
|
|
BLAKE2b-256 checksum How to use checksums |
1d823140d5bb84083a7a5ddc3c5141404e5852dc01e1ac44e7827bdf4c96e90e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
|
Release files / flow_network-0.1.13-cp38-cp38-macosx_10_9_x86_64.whl
| Download URL | flow_network-0.1.13-cp38-cp38-macosx_10_9_x86_64.whl |
|---|---|
| Size | 97.5 kB |
| Tags | CPython 3.8 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
f49d4dbedffdb2c9aed04d37cfe377699a7e677e9529362f72bcbb2f22b8890d
|
|
BLAKE2b-256 checksum How to use checksums |
321938f7f8e9d9563e02d5df0173d0e46fe0cd928029946a3077c5c4d116b6f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
|
Release files / flow_network-0.1.13-cp37-cp37m-manylinux2010_x86_64.whl
| Download URL | flow_network-0.1.13-cp37-cp37m-manylinux2010_x86_64.whl |
|---|---|
| Size | 637.0 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
4d2ccb35c4b59419b0ef51060bd2e9f2480bb77d353f531fcdc99ebc59fbed48
|
|
BLAKE2b-256 checksum How to use checksums |
7982255393f073d98b3eeaebe7537e45050b0b099ad1e3308e3bc4784957fdca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
|
Release files / flow_network-0.1.13-cp37-cp37m-manylinux1_x86_64.whl
| Download URL | flow_network-0.1.13-cp37-cp37m-manylinux1_x86_64.whl |
|---|---|
| Size | 637.0 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
d7ac4c85e2105c116b5b1b9f477e1b0ca4fcf05f1874b0eb040203e74a2f2477
|
|
BLAKE2b-256 checksum How to use checksums |
cd19d994419a39d7582fe7742134bd984990ed56540cad81aa25ceea7e3e8eba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
|
Release files / flow_network-0.1.13-cp36-cp36m-manylinux2010_x86_64.whl
| Download URL | flow_network-0.1.13-cp36-cp36m-manylinux2010_x86_64.whl |
|---|---|
| Size | 636.0 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
49b9c7556666b87310565f3bdee1fb70e830bfbc33657c87e0e5d5837d550183
|
|
BLAKE2b-256 checksum How to use checksums |
1835a6a151ce471b651e5579b4e4a6a351c4dabca524bb510c610da74bac8b0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
|
Release files / flow_network-0.1.13-cp36-cp36m-manylinux1_x86_64.whl
| Download URL | flow_network-0.1.13-cp36-cp36m-manylinux1_x86_64.whl |
|---|---|
| Size | 636.0 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
75d0b33fd6ad3db463379263b242b13878e6a419bdfcb71179444a79dd2e1e1d
|
|
BLAKE2b-256 checksum How to use checksums |
af280635c3c3b5b64c795f129772662b6f751e08ef60c25d73d96c54a17256b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10
|
Security for flow-network 0.1.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.