
    Αi7                          " S  S5      r g)c                   4    \ rS rSrSrS	S jrS rS rS rSr	g)
	UnionFind   a  Union-find data structure.

Union-find is a data structure that keeps track of a set of elements partitioned
into a number of disjoint (non-overlapping) subsets.

Reference:
https://en.wikipedia.org/wiki/Disjoint-set_data_structure

Args:
  elements(list): The initialize element list.
Nc                    / U l         0 U l        SU l        U(       d  / nU Hc  nU R                   R                  U R                  5        U R                  R	                  X R                  05        U =R                  S-  sl        Me     g )N       )_parents_index	_curr_idxappendupdate)selfelementseles      k/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/distributed/transpiler/details/ufind.py__init__UnionFind.__init__   sf    HCMM  0KK^^45NNaN     c                     XR                   ;  a  gU R                   U   nX R                  U   :w  aA  U R                  U   nU R                  U   U R                  U'   UnX R                  U   :w  a  MA  U$ )N)r	   r   )r   xidxts       r   findUnionFind.find(   so     KKkk!n]]3''c"A!%q!1DMM#C ]]3'' 
r   c                 p    U R                  U5      nU R                  U5      nX4:X  a  g X@R                  U'   g N)r   r   )r   r   yx_rooty_roots        r   unionUnionFind.union4   s1    11 &fr   c                 H    U R                  U5      U R                  U5      :H  $ r   )r   )r   r   r   s      r   is_connectedUnionFind.is_connected=   s     yy|tyy|++r   )r
   r	   r   r   )
__name__
__module____qualname____firstlineno____doc__r   r   r    r#   __static_attributes__ r   r   r   r      s    
	 
',r   r   N)r   r+   r   r   <module>r,      s    0, 0,r   