Skip to main content

Disjoint Union

Implementation of the union find algorithm. This library will work with all hashable objects.

Installation

PyPI

python3 -m pip install disjoint_union

Usage

DisjointUnion is a subclass of list and can be instantiated by passing it an iterable.

You can use the | and + operators on a DisjointUnion to create a new DisjointUnion, or you can mutate the original union using the |= and += assignment operators, or the union(x, y) and unions(*iterable) methods.

In [1]: from disjoint_union import DisjointUnion
In [2]: d = DisjointUnion(range(5))
In [3]: d
Out[3]: [{0, 1, 2, 3, 4}]

In [4]: d | range(6, 10)
Out[4]: [{0, 1, 2, 3, 4}, {6, 7, 8, 9}]

In [5]: d |= range(6, 10)
In [6]: d
Out[6]: [{0, 1, 2, 3, 4}, {6, 7, 8, 9}]

In [7]: d.union(2, 5)
Out[7]: [{0, 1, 2, 3, 4, 5}, {6, 7, 8, 9}]

In [8]: d |= (5, 6)
In [9]: d
Out[9]: [{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}]

In [10]: d |= range(10, 15)
In [11]: d
Out[11]: [{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {10, 11, 12, 13, 14}]

In [12]: d | (9, 10, 15)
Out[12]: [{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}]

Metadata

Release files for disjoint-union 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for disjoint-union 0.5.0
File Size Uploaded
disjoint_union-0.5.0.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for disjoint-union 0.5.0
File Interpreter ABI Platform
disjoint_union-0.5.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 11.7 kB

Release files / disjoint_union-0.5.0.tar.gz

Download URL disjoint_union-0.5.0.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5ca175968c3aad3ceb61f1e5159396dcd73e9169f642992205b1608ef4ab63a7
BLAKE2b-256 checksum
How to use checksums
985a3b8334a1d8dafa3fac6e8c36bfb4c86e8230824329cb4b94920836ab2238
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release files / disjoint_union-0.5.0-py2.py3-none-any.whl

Download URL disjoint_union-0.5.0-py2.py3-none-any.whl
Size 6.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
0da41b821465c3c8ae64ba049eacf1cae7c433cf977376d4dcbc5975cc1a8e6f
BLAKE2b-256 checksum
How to use checksums
90a1fee4593f62f1586411e5311d1b7b8b5ce7a5652c823a3e294a6eca6df965
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page