A thin Python wrapper for the Hochbaum Pseudo Flow (HPF) fast s-t min-cut/max-flow algorithm
Project description
Thin wrapper for HPF
Thin Python wrapper for the non-parametric Hochbaum Pseudoflow (HPF) min-cut/max-flow algorithm. The original source code by Bala Chandran and Dorit S. Hochbaum is availbable here. The C++ code used in this wrapper has been refractored by Patrick M. Jensen and published here.
Installation
Install from repository (requires Cython
):
git clone https://github.com/Skielex/thinhpf
cd thinhpf
pip install .
Package will be made available on PyPI later.
Tiny example
import thinhpf
hpf = thinhpf.hpf()
# Add s and t.
next_node_id = hpf.add_node(2)
def offset(n):
return 2 + n
s = 0
t = 1
hpf.set_source(0)
hpf.set_sink(1)
# Number of nodes to add.
nodes_to_add = 2
# Add two nodes.
next_node_id = hpf.add_node(nodes_to_add)
# Add edges.
hpf.add_edge(s, offset(0), 5) # s --5-> n(0)
hpf.add_edge(offset(0), t, 1) # n(0) --1-> t
hpf.add_edge(offset(1), t, 3) # n(1) --3-> t
hpf.add_edge(offset(0), offset(1), 2) # n(0) --2-> n(1)
hpf.add_edge(offset(1), offset(0), 1) # n(1) --1-> n(0)
# Find maxflow/cut hpf.
hpf.mincut()
flow = hpf.compute_maxflow()
for n in range(nodes_to_add):
segment = hpf.what_label(n)
print('Node %d has label %d.' % (n, segment))
# Node 0 has label 0.
# Node 1 has label 1.
print('Flow: %s' % flow)
# Maximum flow: 3
Related repositories
- Hochbaum Group on GitHub
- Original source website
- slgbuilder Python package (CVPR 2020)
- shrdr Python package (ICCV 2021)
- thinqpbo Python package
- thinmaxflow Python package
- C++ implementations of max-flow/min-cut algorithms
License
The original C code by Bala Chandran and Dorit S. Hochbaum and thereby the content of hpf.h
(previously pseudo.c
) is published under an academic license (see LICENSE file). More information on the original website.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file thinhpf-0.1.1.tar.gz
.
File metadata
- Download URL: thinhpf-0.1.1.tar.gz
- Upload date:
- Size: 187.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba43faa692ea6a81433863166d2162ea9ff9d49a82048d3f0e93624e52f383f4 |
|
MD5 | 4689cfe5f394a41694a26c56577c7be0 |
|
BLAKE2b-256 | 06d90a4625750c6c78ec30dc4eb1a48287be000e195e95b2a8a88dde75cb53af |
File details
Details for the file thinhpf-0.1.1-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: thinhpf-0.1.1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 125.0 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e3437b215f73df745ece7a847af928cce7614063d406f25d6ded0ea9ba1f4d3 |
|
MD5 | cff8bb0c6e460a086cd307b1a4def469 |
|
BLAKE2b-256 | 07c8d3051b75956c59c045fe491f53cfd7e21bba99fc161f6e986d7e575419ae |
File details
Details for the file thinhpf-0.1.1-cp310-cp310-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: thinhpf-0.1.1-cp310-cp310-macosx_10_15_x86_64.whl
- Upload date:
- Size: 170.5 kB
- Tags: CPython 3.10, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d40532c958a5d28852adf26e61f72dac3c9dc00c033dedcd5530ec2b1f1c78e |
|
MD5 | b2de716592fb2be583cc507468654174 |
|
BLAKE2b-256 | ba558e36bedb452de32e17650755636c56b3446e62ba5faeefc271604b83b4c1 |
File details
Details for the file thinhpf-0.1.1-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: thinhpf-0.1.1-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 125.6 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f7d9e14e0d79c2a52489512e1f48489636f15e7d9acba466cbd605a770a132e |
|
MD5 | 36090d8f1e0fb71b445603641c086ed8 |
|
BLAKE2b-256 | 4fadb37882616c315f561a7bcc1c3d9dee79a85e5e2372b38e6275658412ee12 |
File details
Details for the file thinhpf-0.1.1-cp39-cp39-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: thinhpf-0.1.1-cp39-cp39-macosx_10_15_x86_64.whl
- Upload date:
- Size: 171.1 kB
- Tags: CPython 3.9, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e279ddd84c4720d45f8129ef492a1aadb8fadd2abad6eb4cd0ba89454913a82 |
|
MD5 | da9587824bf1f8bccd900143dcb8ca09 |
|
BLAKE2b-256 | c4cac3b54198a28a06aa824dea3e54dd542a821a6bc6ea897a1033f2fdaa5923 |
File details
Details for the file thinhpf-0.1.1-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: thinhpf-0.1.1-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 125.8 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b71ee2b72e9509e0f8055b31026b1ae70097616003bd17be8840883c0fd0cabd |
|
MD5 | 3440eca68f6286667df13862a0b5a8d0 |
|
BLAKE2b-256 | 5a5b680e31e1a0e96ba99546ba996bebc807d11a5a739723a6266dc2d705c3a1 |
File details
Details for the file thinhpf-0.1.1-cp38-cp38-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: thinhpf-0.1.1-cp38-cp38-macosx_10_14_x86_64.whl
- Upload date:
- Size: 170.6 kB
- Tags: CPython 3.8, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2e1be8eedd28cd4b85f04a1dfb90cf337fe85301ac038a9193666b1ac077c5f |
|
MD5 | cf18078ab2acfe7a65940efa9cdeb6bb |
|
BLAKE2b-256 | 8d91affa2b9cf52a56de1f78354794add366a71746a4a59103c59a0bb45735cf |
File details
Details for the file thinhpf-0.1.1-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: thinhpf-0.1.1-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 126.3 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c8cb2a87ddad6e6e235030090d1a789b94a104da06cefee650d81e51e2cf7e7 |
|
MD5 | 68ae7198ef6b3178139f8485c4b6148e |
|
BLAKE2b-256 | b5ad36f8b1b82ce7a9614309cb65e3ce514fbac2dff0705ff13e143db3866c75 |
File details
Details for the file thinhpf-0.1.1-cp37-cp37m-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: thinhpf-0.1.1-cp37-cp37m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 170.2 kB
- Tags: CPython 3.7m, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6284d702311e34d3eed26def71b9e5de602b561532174cbf9908e85f5af752f5 |
|
MD5 | d3815736f93ebd7fd9e00ccb01dcdd5f |
|
BLAKE2b-256 | 2ce67ac8a17759078171006d6322e4e1bd14c0d94b2a304942b62c43715176d7 |