PyUF: Python Union-Find
Implementation of the Union-Find data structure in Python.
Data is divided into different groups (“partitions”). Each group has a name, and a set of objects. Over this setup, we want to support two operations:
find(x): Return the name of the group where x belongs to.
union(g1, g2): Given two groups, merge them into one. The new meta-group contains all the elements from g1 and g2.
Example usage:
>>> space = UnionFindSpace(
Partition("letters", "abcdef"),
Partition("numbers", range(5)),
)
>>> space.find("a")
letters
>>> space.find(1)
numbers
>>> partition = space.union("letters", "numbers")
>>> partition.name
letters_numbers
# It's possible to indicate the name of the group
>>> partition = space.union("letters", "numbers", "alpha")
>>> partition.name
alpha
Development
In order to start working or testing with this repository, you’ll need to create and activate a new virtual environment. Respectively, the commands are the following ones
$ python3 -m venv env
$ source env/bin/activate
After that you can setup the environment with:
$ make install-dev
$ make test
Make sure that:
The test pass successfully
The code is properly formatted (this can be checked with make lint and corrected with make format).
Release files for pyuf 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyuf-0.1.2.tar.gz | 2.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyuf-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.5 kB
Release files / pyuf-0.1.2.tar.gz
| Download URL | pyuf-0.1.2.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
401449dab444fcd001283166f299170a7e11c282b2524ba859faf682a0d1525a
|
|
BLAKE2b-256 checksum How to use checksums |
706be6a4004a78e8e41f0f77150ed8dfcb977d5141e59d305232b717235d0a72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.0
|
Release files / pyuf-0.1.2-py3-none-any.whl
| Download URL | pyuf-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5363345124d823117f18375a987600bf1af91782c219365f339ed703097e2d7d
|
|
BLAKE2b-256 checksum How to use checksums |
a922191801ce4e7fd23160d39661f16798adc40f4b40017a4958e46bc238112b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.0
|