Disjoint Set Union (Union-Find) data structure with path compression and union by size
Project description
DSU Package
A Python implementation of the Disjoint Set Union (DSU) data structure, also known as Union-Find. This package provides efficient methods for union and find operations, commonly used in graph algorithms and connectivity problems.
Features
- Efficient union and find operations
- Path compression
- Suitable for competitive programming and algorithmic tasks
Installation
You can install the package using pip:
pip install .
Usage
from dsu_package.dsu import DSU
dsu = DSU(5)
dsu.union(0, 1)
dsu.union(1, 2)
print(dsu.find(2)) # Output: 0
Testing
Run the unit tests using:
python -m unittest discover -s dsu_package/tests
License
This project is licensed under the MIT License. See the LICENSE file for details.
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dsu_package-0.1.0.tar.gz.
File metadata
- Download URL: dsu_package-0.1.0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
162fe9262eade7fe63074fe0874fc44b10fca5f923f082893574bf60fd6cf59f
|
|
| MD5 |
5463cd6d6eb5895292a0844eeb0df927
|
|
| BLAKE2b-256 |
168f4d2736e823f664e69b9f8cf017a3c8dbc6b627434b111f104b7245092606
|
File details
Details for the file dsu_package-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dsu_package-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
706a59bbd18f56d424b90b4523983f272289c73755e6035a3727b76a56798501
|
|
| MD5 |
81709f67e7e3259bc0fb78d56138e1ad
|
|
| BLAKE2b-256 |
b9845242ada6be13c945444bcaafed704fea2b3b88f2e83aec0ad9d622ed09be
|