Skip to main content

UFx is a pure python library that implements the disjoint-set data structure which allows the union-find operations.

Two implementations are proposed.

  • uf_hash using python dictionary

  • uf_tree using nodes linked each to its ansestror

Those implementations are design for hashable types. However it is possible to use the UFNode class present in the uf_tree implementation with non-hashable types (see the API documentation part below).

UFx was only tested with python 2.7, python 3.5 and pypy but may work with other versions python virtual machines.

Performances

The uf_hash implementation is the recommanded one. It performs well with the classic python virtual machine. The uf_tree implementation is really slow due to the poor performances of python with pointer like based data structures. The use of another python virtual machine like pypy its recommanded when using the uf_tree implementation.

TODO: Table of computation speed and memory consumption

API documentation

Import

You can import one of the implementation of the disjoint-set data structure

from ufx import uf_tree as ufx

or

from ufx import uf_hash as ufx

Quick Example

import sys
import random
uf = ufx.UnionFind()
az = "abcdefghijklmnopqrstuvwxyz"
az += az.upper()
for e in az:
    uf.make_set(e)
i = 0
while i < 26:
    i += 1
    uf.union(random.choice(az), random.choice(az))
print(uf)
print(uf.get_size('a'))
uf.clear()
print(uf)

Hashable types

TODO

Non-hashable types

Look on the class UFNode

Metadata

Release files for UFx 1.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 UFx 1.0
File Size Uploaded Provenance
UFx-1.0.0.tar.gz 4.6 kB Without provenance Details

Release files / UFx-1.0.0.tar.gz

Download URL UFx-1.0.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
94b9d11dbe6847fb6994c768e5259f7b625cfcdd016e09dbcff1aac89a75be51
BLAKE2b-256 checksum
How to use checksums
4b333cabcd51f4f9ec345cfc9667a8638a7df86d3c11a2ac5ee9643830698c1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for UFx 1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0 This release

1 release file No provenance

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