Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/papachristoumarios/python-gomoryhu
Simplistic Gomory-Hu Tree Data Structure implementation in Python
https://github.com/papachristoumarios/python-gomoryhu
data-structures gomory-hu-tree maximum-flow minimum-cu python
Last synced: 2 months ago
JSON representation
Simplistic Gomory-Hu Tree Data Structure implementation in Python
- Host: GitHub
- URL: https://github.com/papachristoumarios/python-gomoryhu
- Owner: papachristoumarios
- License: mit
- Created: 2018-08-18T09:43:13.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-09T19:35:19.000Z (over 6 years ago)
- Last Synced: 2024-10-07T18:09:00.116Z (3 months ago)
- Topics: data-structures, gomory-hu-tree, maximum-flow, minimum-cu, python
- Language: Python
- Size: 3.91 KB
- Stars: 13
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gomory-Hu Tree Data Structure Implementation in Python
## Description
This repository contains a simple implementation of the [Gomory-Hu tree data structure](https://en.wikipedia.org/wiki/Gomory%E2%80%93Hu_tree) that allows for efficient computation of minimum s-t cuts in a network via precomputing a tree.
It constructs a tree by doing minimum cuts in the original network splitting it gradually into components. Finally, when the tree is constructed, one can query a minimum cut by doing a tree traversal on the Gomory-Hu Tree and keeping the minimum cost from s to t.
## Implementation
This is a very simple implementation of the data structure and the algorithm used in constructing it. The Ford-Fulkerson algorithm is used to compute maximum flow / minimum cut. There are also faster flow algorithms available (e.g. Edmonds-Karp, Dinic). The algorihtm can also be parallelized for faster computation.
## Installation
The code can be installed with `distutils` via:
```bash
python3 setup.py install
```## Usage
1. See `example.py` for instructions on using the GomoryHuTree class for constructing Gomory-Hu trees.
2. The API docs are accesible via the `help(gomory_hu)` command in a python prompt.