Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/deehzee/unionfind
A union-find disjoint sets data structure implemented in Python with the "Weighted Quick Union with Path Compression" algorithm.
https://github.com/deehzee/unionfind
algorithms-datastructures union-by-rank-and-path-compression union-find
Last synced: about 2 months ago
JSON representation
A union-find disjoint sets data structure implemented in Python with the "Weighted Quick Union with Path Compression" algorithm.
- Host: GitHub
- URL: https://github.com/deehzee/unionfind
- Owner: deehzee
- License: mit
- Created: 2017-06-07T06:30:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-10-07T18:54:25.000Z (about 3 years ago)
- Last Synced: 2024-08-01T15:29:55.166Z (5 months ago)
- Topics: algorithms-datastructures, union-by-rank-and-path-compression, union-find
- Language: Python
- Size: 7.81 KB
- Stars: 65
- Watchers: 5
- Forks: 20
- Open Issues: 4
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
UnionFind Implementation in Python
==================================Union-find is a data structure that maintains disjoint set (called connected
components or components in short) membership, and makes it easier to merge
(union) two components, and to find if two elements are connected (i.e., belong
to the same component).This implements the "weighted-quick-union-with-path-compression" union-find
algorithm. Only works if elements are immutable objects.Worst case for union and find :math:`(N + M \log^* N)`, with :math:`N` elements
and :math:`M` union/find operations. The function :math:`\log^*` is the number
of times needed to take :math:`\log` (base 2) of a number until reaching 1. In
practice, the amortized cost of each operation is nearly linear [1]_.**Update:** This has now been packaged into an instalable pip package by
Hagai Helman Tov (@hagai-helman).
See the fork at https://github.com/hagai-helman/unionfind).Contents
--------* Module ``unionfind`` with the class ``UnionFind``
* An example notebook ``UnionFindExamples.ipynb``
* License: MIT.
Requirements
------------* ``numpy``
.. [1] http://algs4.cs.princeton.edu/lectures/