Skip to main content

A simple Union Find Class for Python.

Project description

Project Name: UF-Toolkit

Description

UF-Toolkit is a Python package providing an efficient and robust implementation of the Union Find algorithm, also known as Disjoint Set Union (DSU). This data structure is essential for managing a set of elements divided into several disjoint, non-overlapping subsets. It's particularly useful in computer science for applications like network connectivity, image segmentation, clustering, and more.

Our implementation offers features like path compression and union by rank, ensuring optimal time complexity for both find and union operations. Whether you're dealing with graph algorithms or just need a fast way to handle disjoint sets, UF-Toolkit is designed to offer straightforward, reliable, and efficient performance.

Features

  • Efficient Union Find Operations: Implements both path compression and union by rank for fast operation.
  • Easy-to-Use API: Designed with simplicity in mind, our API makes it easy to integrate into your existing Python projects.
  • Versatile Applications: Suitable for use cases ranging from network analysis to algorithmic problem solving in competitive programming.
  • Fully Documented: Each method and class is thoroughly documented, making it easy to get started and understand how the package works.

Installation

Install UF-Toolkit using pip:

pip install uf-toolkit

Usage

Here's a quick example of how to use UF-Toolkit:

from uf_toolkit import UnionFind

Create a Union Find instance with 10 elements

uf = UnionFind(10)

Union some sets

uf.union(1, 2)
uf.union(2, 3)

Check if two elements are in the same set

print(uf.connected([1, 3])) # True

Count the number of distinct sets

print(uf.count_sets()) # 3

Check all elements of the set that contains given element

print(uf.get_all_elements_of_set(1)) # [1, 2, 3]

Requirements

Python 3.x

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check issues page.

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Chas Huggins - hugginsc10@gmail.com

Project Link: https://github.com/hugginsc10/uf-toolkit/

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

uf-toolkit-0.2.2.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uf_toolkit-0.2.2-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file uf-toolkit-0.2.2.tar.gz.

File metadata

  • Download URL: uf-toolkit-0.2.2.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.6

File hashes

Hashes for uf-toolkit-0.2.2.tar.gz
Algorithm Hash digest
SHA256 9ac50241a220c7f0494ebcad5252253e92b90d981d8784e26b43b8db20042929
MD5 3861c4fc605191a612c0c49d5b26bf08
BLAKE2b-256 5e32f72754e194c0595f31e2eb2e9c5a58aaa59cb3da4818a41fba6790c70fd7

See more details on using hashes here.

File details

Details for the file uf_toolkit-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: uf_toolkit-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.6

File hashes

Hashes for uf_toolkit-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9ff9206faa462ee64d31ec7c6865eb79ef4ba0e3d908d869df0a01d2fd853939
MD5 2503fc66c342a5cc63210d884d10e9ac
BLAKE2b-256 aebb4e4fbe6ce304f463b07851cd6f32614c78854575de469db68b21185ed62c

See more details on using hashes here.

Supported by

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