Skip to main content

Flow Network Python Library

Project description

Flow Network

网络流的工业级应用

Release Drafter Upload Python Package

使用 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)  # 边的起点、终点、流过的流量、最大容量、单位流量的费用

测试代码

tests.py

Reference

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flow-network-0.1.13.tar.gz (63.4 kB view details)

Uploaded Source

Built Distributions

flow_network-0.1.13-cp39-cp39-manylinux2010_x86_64.whl (640.4 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

flow_network-0.1.13-cp39-cp39-manylinux1_x86_64.whl (640.4 kB view details)

Uploaded CPython 3.9

flow_network-0.1.13-cp38-cp38-win_amd64.whl (100.5 kB view details)

Uploaded CPython 3.8 Windows x86-64

flow_network-0.1.13-cp38-cp38-manylinux2010_x86_64.whl (635.1 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

flow_network-0.1.13-cp38-cp38-manylinux1_x86_64.whl (635.1 kB view details)

Uploaded CPython 3.8

flow_network-0.1.13-cp38-cp38-macosx_10_9_x86_64.whl (97.5 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

flow_network-0.1.13-cp37-cp37m-manylinux2010_x86_64.whl (637.0 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

flow_network-0.1.13-cp37-cp37m-manylinux1_x86_64.whl (637.0 kB view details)

Uploaded CPython 3.7m

flow_network-0.1.13-cp36-cp36m-manylinux2010_x86_64.whl (636.0 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

flow_network-0.1.13-cp36-cp36m-manylinux1_x86_64.whl (636.0 kB view details)

Uploaded CPython 3.6m

File details

Details for the file flow-network-0.1.13.tar.gz.

File metadata

  • Download URL: flow-network-0.1.13.tar.gz
  • Upload date:
  • Size: 63.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for flow-network-0.1.13.tar.gz
Algorithm Hash digest
SHA256 1a5ed54ae2dc2dff44d85ba3642ed535e5b3a7e12148556cd77426a336de980b
MD5 4a3c8ad55a3d787d7fc09655e897dc4e
BLAKE2b-256 7aa2521c51b8fa3d0e9d62f1bc5d04123137d84334f715a8708d5871b141c800

See more details on using hashes here.

File details

Details for the file flow_network-0.1.13-cp39-cp39-manylinux2010_x86_64.whl.

File metadata

  • Download URL: flow_network-0.1.13-cp39-cp39-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 640.4 kB
  • Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
  • Uploaded using 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

File hashes

Hashes for flow_network-0.1.13-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 94dd1e8b73983bf4a6f7fb17e8cbd604e11cb1fbd9f0dae333a0f02fb6d122c2
MD5 0f75c26b82fe0e8badea889b311c6597
BLAKE2b-256 2763f8b466c947ca199c23e705526de24f0b87f0994539cd480c0cb03b5f1097

See more details on using hashes here.

File details

Details for the file flow_network-0.1.13-cp39-cp39-manylinux1_x86_64.whl.

File metadata

  • Download URL: flow_network-0.1.13-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 640.4 kB
  • Tags: CPython 3.9
  • Uploaded using 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

File hashes

Hashes for flow_network-0.1.13-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 55815d0632b3e74afb90b56e3dc502889a090f5e42d91201760f4629c03cdc5f
MD5 13b90297c14597babb3f53567f20998a
BLAKE2b-256 82424456fd935958fc21566be8a5613e442e979613ec9639d21883b75b1745bb

See more details on using hashes here.

File details

Details for the file flow_network-0.1.13-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: flow_network-0.1.13-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 100.5 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for flow_network-0.1.13-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 121f1b3434cef704ee0f61007a439dfe757b0bb131aab81cdc6bacf7b39acf47
MD5 1058d2fa7ff78b282d43b20155f26109
BLAKE2b-256 53d4eac679724aac131616a8fba06ac6b0e569a6aeca986028b6cbca271ca0b2

See more details on using hashes here.

File details

Details for the file flow_network-0.1.13-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: flow_network-0.1.13-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 635.1 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using 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

File hashes

Hashes for flow_network-0.1.13-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 813e93a47aa4d1f7c231fce42b2a55a028b6e7b960f941b22f56fbfec61199bc
MD5 fa781c4cd657bfb0a1da4886e909e5aa
BLAKE2b-256 ebbd0f92bca457210a359cb3b2cf36b72b7f0923c4bb0ae5c4a0a8166c297082

See more details on using hashes here.

File details

Details for the file flow_network-0.1.13-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: flow_network-0.1.13-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 635.1 kB
  • Tags: CPython 3.8
  • Uploaded using 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

File hashes

Hashes for flow_network-0.1.13-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ee4fe85bf7fa43019e17471e27b9358571111493746cb8bf6897f4484044ff8f
MD5 5413607f6d8938d249714228273b0b10
BLAKE2b-256 1d823140d5bb84083a7a5ddc3c5141404e5852dc01e1ac44e7827bdf4c96e90e

See more details on using hashes here.

File details

Details for the file flow_network-0.1.13-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: flow_network-0.1.13-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 97.5 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using 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

File hashes

Hashes for flow_network-0.1.13-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f49d4dbedffdb2c9aed04d37cfe377699a7e677e9529362f72bcbb2f22b8890d
MD5 96e34edccf1b5b035e1cbc7063b70975
BLAKE2b-256 321938f7f8e9d9563e02d5df0173d0e46fe0cd928029946a3077c5c4d116b6f7

See more details on using hashes here.

File details

Details for the file flow_network-0.1.13-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: flow_network-0.1.13-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 637.0 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using 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

File hashes

Hashes for flow_network-0.1.13-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 4d2ccb35c4b59419b0ef51060bd2e9f2480bb77d353f531fcdc99ebc59fbed48
MD5 d19cc4fec6d813b7985e6c0003000b6a
BLAKE2b-256 7982255393f073d98b3eeaebe7537e45050b0b099ad1e3308e3bc4784957fdca

See more details on using hashes here.

File details

Details for the file flow_network-0.1.13-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: flow_network-0.1.13-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 637.0 kB
  • Tags: CPython 3.7m
  • Uploaded using 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

File hashes

Hashes for flow_network-0.1.13-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d7ac4c85e2105c116b5b1b9f477e1b0ca4fcf05f1874b0eb040203e74a2f2477
MD5 9bf78a40462b634abffa0dc0aa67aba3
BLAKE2b-256 cd19d994419a39d7582fe7742134bd984990ed56540cad81aa25ceea7e3e8eba

See more details on using hashes here.

File details

Details for the file flow_network-0.1.13-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: flow_network-0.1.13-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 636.0 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using 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

File hashes

Hashes for flow_network-0.1.13-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 49b9c7556666b87310565f3bdee1fb70e830bfbc33657c87e0e5d5837d550183
MD5 c8a9cfba7d75f2c93a368ea63bf38ac7
BLAKE2b-256 1835a6a151ce471b651e5579b4e4a6a351c4dabca524bb510c610da74bac8b0f

See more details on using hashes here.

File details

Details for the file flow_network-0.1.13-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: flow_network-0.1.13-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 636.0 kB
  • Tags: CPython 3.6m
  • Uploaded using 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

File hashes

Hashes for flow_network-0.1.13-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 75d0b33fd6ad3db463379263b242b13878e6a419bdfcb71179444a79dd2e1e1d
MD5 68d90d32ab7f8bda711981ec81e543e6
BLAKE2b-256 af280635c3c3b5b64c795f129772662b6f751e08ef60c25d73d96c54a17256b5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page