ó
    †~i
  ã                   ó(   • S r SSKJr   " S S5      rg)z
Union-find data structure.
é    )Úgroupsc                   ó:   • \ rS rSrSrS
S jrS rS rS rS r	S	r
g)Ú	UnionFindé   aP  Union-find data structure.

Each unionFind instance X maintains a family of disjoint sets of
hashable objects, supporting the following two methods:

- X[item] returns a name for the set containing the given item.
  Each set is named by an arbitrarily-chosen one of its members; as
  long as the set remains unchanged it will keep the same name. If
  the item is not yet part of a set in X, a new singleton set is
  created for it.

- X.union(item1, item2, ...) merges the sets containing each item
  into a single larger set.  If any item is not yet part of a set
  in X, it is added to X as one of the members of the merged set.

  Union-find data structure. Based on Josiah Carlson's code,
  https://code.activestate.com/recipes/215912/
  with significant additional changes by D. Eppstein.
  http://www.ics.uci.edu/~eppstein/PADS/UnionFind.py

Nc                 óv   • Uc  Sn0 U l         0 U l        U H   nSU R                  U'   X R                   U'   M"     g)z¦Create a new empty union-find structure.

If *elements* is an iterable, this structure will be initialized
with the discrete partition on the given set of elements.

N© é   ©ÚparentsÚweights)ÚselfÚelementsÚxs      ÚV/home/mande/repo/quber/.venv/lib/python3.13/site-packages/networkx/utils/union_find.pyÚ__init__ÚUnionFind.__init__   s?   € ð ÑØˆHØˆŒØˆŒÛˆAØˆD�L‰L˜‰OØ�L‰L˜‹Oò ó    c                 ó  • XR                   ;  a  XR                   U'   SU R                  U'   U$ / nU R                   U   nX1:w  a)  UR                  U5        UnU R                   U   nX1:w  a  M)  U H  nX0R                   U'   M     U$ )z:Find and return the name of the set containing the object.r	   )r   r   Úappend)r   ÚobjectÚpathÚrootÚancestors        r   Ú__getitem__ÚUnionFind.__getitem__.   sŠ   € ð Ÿ™Ó%Ø#)�L‰L˜Ñ Ø#$ˆD�L‰L˜Ñ ØˆMð ˆØ�|‰|˜FÑ#ˆØ‹nØ�K‰K˜ÔØˆFØ—<‘< Ñ'ˆDð �nó ˆHØ%)�L‰L˜Ó"ñ àˆr   c                 ó,   • [        U R                  5      $ )zBIterate through all items ever found or unioned by this structure.)Úiterr   )r   s    r   Ú__iter__ÚUnionFind.__iter__D   s   € ä�D—L‘LÓ!Ð!r   c              #   ó”   #   • U R                    H  nX   nM	     [        U R                   5      R                  5        Sh  v•N   g N7f)a  Iterates over the sets stored in this structure.

For example::

    >>> partition = UnionFind("xyz")
    >>> sorted(map(sorted, partition.to_sets()))
    [['x'], ['y'], ['z']]
    >>> partition.union("x", "y")
    >>> sorted(map(sorted, partition.to_sets()))
    [['x', 'y'], ['z']]

N)r   r   Úvalues)r   r   Ú_s      r   Úto_setsÚUnionFind.to_setsH   s9   é € ð —”ˆAØ‘ŠAñ ô ˜$Ÿ,™,Ó'×.Ñ.Ó0×0Ó0ùs   ‚>AÁ AÁAc           	      ó  ^ • [        [        U Vs1 s H  nT U   iM
     snU 4S jSS95      n [        U5      nU H6  nT R                  U==   T R                  U   -  ss'   UT R
                  U'   M8     gs  snf ! [         a     gf = f)z8Find the sets containing the objects and merge them all.c                 ó"   >• TR                   U    $ ©N)r   )Úrr   s    €r   Ú<lambda>Ú!UnionFind.union.<locals>.<lambda>`   s   ø€ ¸$¿,¹,Àqº/r   T)ÚkeyÚreverseN)r   ÚsortedÚnextÚStopIterationr   r   )r   Úobjectsr   Úrootsr   r(   s   `     r   ÚunionÚUnionFind.union[   s�   ø€ ô ÜÙ")Ó*¢'˜Q��a”¡'Ñ*Ô0IÐSWñó
ˆð
	Ü˜“;ˆDó ˆAØ�L‰L˜Ó $§,¡,¨q¡/Ñ1ÓØ"ˆD�L‰L˜‹Oò ùò +øô
 ó 	Ùð	ús   �A7¯A< Á<
B	ÂB	r
   r'   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r#   r2   Ú__static_attributes__r   r   r   r   r      s    † ñô, òò,"ò1õ&#r   r   N)r8   Únetworkx.utilsr   r   r   r   r   Ú<module>r;      s   ðñõ "÷b#ò b#r   