+
    )i
                     *    R t ^ RIHt  ! R R4      tR# )z
Union-find data structure.
)groupsc                   F   a  ] tR t^t o RtR	R ltR tR tR tR t	Rt
V tR# )
	UnionFindaP  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                z    Vf   Rp/ V n         / V n        V F   p^V P                  V&   W P                   V&   K"  	  R# )zCreate 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   && W/var/www/html/photoedit/myenv/lib/python3.14/site-packages/networkx/utils/union_find.py__init__UnionFind.__init__   s?     HADLLOLLO     c                   WP                   9  d    WP                   V&   ^V P                  V&   V# . pV P                   V,          pW18w  d)   VP                  V4       TpV P                   V,          pK.  V F  pW0P                   V&   K  	  V# )z:Find and return the name of the set containing the object.)r   r	   append)r
   objectpathrootancestors   &&   r   __getitem__UnionFind.__getitem__.   s     %#)LL #$DLL M ||F#nKKF<<'D H%)LL" r   c                ,    \        V P                  4      # )zBIterate through all items ever found or unioned by this structure.)iterr   )r
   s   &r   __iter__UnionFind.__iter__D   s    DLL!!r   c              #     "   V P                    F  pW,          pK  	  \        V P                   4      P                  4        Rj  xL
  R#  L5i)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0s   AAAAc           	     B  a  \        \        V Uu0 uF  pS V,          kK  	  upV 3R lRR7      4      p \        V4      pT FB  pS P                  T;;,          S P                  T,          ,          uu&   TS P
                  T&   KD  	  R# u upi   \         d     R# i ; i)z8Find the sets containing the objects and merge them all.c                 *   < SP                   V ,          # 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   f*    r   unionUnionFind.union[   s     ")*'Qa'*0ISW

	;D ALL$,,q/1"DLLO  +
  		s   B
B BBr   r$   )__name__
__module____qualname____firstlineno____doc__r   r   r   r    r/   __static_attributes____classdictcell__)__classdict__s   @r   r   r      s(     , ,"1&# #r   r   N)r5   networkx.utilsr   r   r   r   r   <module>r:      s    "b# b#r   