Metadata-Version: 2.1
Name: pyuf
Version: 0.1.0
Summary: Union-Find data structure implementation in Python
Home-page: UNKNOWN
Author: Mariano Anaya
Author-email: marianoanaya@gmail.com
License: MIT
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent

PyUF: Python Union-Find
=======================

Implementation of the ``Union-Find`` data structure in Python.

Data is divided into different groups ("partitions"). Each group has a name,
and a set of objects. Over this setup, we want to support two operations:

    * ``find(x)``: Return the name of the group where x belongs to.
    * ``union(g1, g2)``: Given two groups, merge them into one. The new
      meta-group contains all the elements from ``g1`` and ``g2``.

Example usage:

.. code:: python

    >>> space = UnionFindSpace(
        Partition("letters", "abcdef"),
        Partition("numbers", range(5)),
    )

    >>> space.find("a")
    letters

    >>> space.find(1)
    numbers

    >>> partition = space.union("letters", "numbers")
    >>> partition.name
    letters_numbers


    # It's possible to indicate the name of the  group

    >>> partition = space.union("letters", "numbers", "alpha")
    >>> partition.name
    alpha


