Disjoint set data structure implementation for Python
Project description
disjoint-set
DisjointSet (a.k.a. union–find data structure or merge–find set) implementation for Python.
Prerequisites
The only requirement is having Python 3 installed, you can verify this by running:
$ python --version
Python 3.7.2
Installation
pip install disjoint-set
You can verify he package was installed to your current environment by running:
$ pip list | grep disjoint-set
disjoint-set 0.0.2
Usage
>>> from disjoint_set import DisjointSet
>>> ds = DisjointSet()
>>> ds.find(1)
1
>>> ds.union(1,2)
>>> ds.find(1)
2
>>> ds.find(2)
2
>>> ds.connected(1,2)
True
>>> ds.connected(1,3)
False
>>> "a" in ds
False
>>> ds.find("a")
'a'
>>> "a" in ds
True
Contributing
Feel free to open any issues on github.
Authors
License
This project is licensed under the MIT License - see the LICENSE.md 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
disjoint_set-0.0.3.tar.gz
(2.8 kB
view hashes)
Built Distribution
Close
Hashes for disjoint_set-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66cbff8c9ab78963bac2c0d0d510856083ce5fc32a71b00f7bd2888e07838209 |
|
MD5 | 66f6ea64beee864c6f25edaafa9e9302 |
|
BLAKE2b-256 | 48fb3c422e798cf653ffbce8d3f31637ca5345dcb304d2375d86257773eecc43 |