class_docstr: Disjoint set data structure for incremental connectivity queries.
  
  .. versionadded:: 1.6.0
  
  Attributes
  ----------
  n_subsets : int
      The number of subsets.
  
  Methods
  -------
  add
  merge
  connected
  subset
  subsets
  __getitem__
  
  Notes
  -----
  This class implements the disjoint set [1]_, also known as the *union-find*
  or *merge-find* data structure. The *find* operation (implemented in
  `__getitem__`) implements the *path halving* variant. The *merge* method
  implements the *merge by size* variant.
  
  References
  ----------
  .. [1] https://en.wikipedia.org/wiki/Disjoint-set_data_structure
  
  Examples
  --------
  >>> from scipy.cluster.hierarchy import DisjointSet
  
  Initialize a disjoint set:
  
  >>> disjoint_set = DisjointSet([1, 2, 3, 'a', 'b'])
  
  Merge some subsets:
  
  >>> disjoint_set.merge(1, 2)
  True
  >>> disjoint_set.merge(3, 'a')
  True
  >>> disjoint_set.merge('a', 'b')
  True
  >>> disjoint_set.merge('b', 'b')
  False
  
  Find root elements:
  
  >>> disjoint_set[2]
  1
  >>> disjoint_set['b']
  3
  
  Test connectivity:
  
  >>> disjoint_set.connected(1, 2)
  True
  >>> disjoint_set.connected(1, 'b')
  False
  
  List elements in disjoint set:
  
  >>> list(disjoint_set)
  [1, 2, 3, 'a', 'b']
  
  Get the subset containing 'a':
  
  >>> disjoint_set.subset('a')
  {'a', 3, 'b'}
  
  Get all subsets in the disjoint set:
  
  >>> disjoint_set.subsets()
  [{1, 2}, {'a', 3, 'b'}]
class_docstr_tok: ["Disjoint","set","data","structure","for","incremental","connectivity","queries",".","..","versionadded",":",":","1.6.0","Attributes","--","--","--","--","--","n_subsets",":","int","The","number","of","subsets",".","Methods","--","--","--","-","add","merge","connected","subset","subsets","__getitem__","Notes","--","--","-","This","class","implements","the","disjoint","set","[","1","]","_",",","also","known","as","the","*","union-find","*","or","*","merge-find","*","data","structure",".","The","*","find","*","operation","(","implemented","in","`","__getitem__","`",")","implements","the","*","path","halving","*","variant",".","The","*","merge","*","method","implements","the","*","merge","by","size","*","variant",".","References","--","--","--","--","--","..","[","1","]","https",":","\/\/en.wikipedia.org\/wiki\/Disjoint-set_data_structure","Examples","--","--","--","--",">",">",">","from","scipy.cluster.hierarchy","import","DisjointSet","Initialize","a","disjoint","set",":",">",">",">","disjoint_set","=","DisjointSet","(","[","1",",","2",",","3",",","'","a","'",",","'","b","'","]",")","Merge","some","subsets",":",">",">",">","disjoint_set.merge","(","1",",","2",")","True",">",">",">","disjoint_set.merge","(","3",",","'","a","'",")","True",">",">",">","disjoint_set.merge","(","'","a","'",",","'","b","'",")","True",">",">",">","disjoint_set.merge","(","'","b","'",",","'","b","'",")","False","Find","root","elements",":",">",">",">","disjoint_set","[","2","]","1",">",">",">","disjoint_set","[","'","b","'","]","3","Test","connectivity",":",">",">",">","disjoint_set.connected","(","1",",","2",")","True",">",">",">","disjoint_set.connected","(","1",",","'","b","'",")","False","List","elements","in","disjoint","set",":",">",">",">","list","(","disjoint_set",")","[","1",",","2",",","3",",","'","a","'",",","'","b","'","]","Get","the","subset","containing","'","a","'",":",">",">",">","disjoint_set.subset","(","'","a","'",")","{","'","a","'",",","3",",","'","b","'","}","Get","all","subsets","in","the","disjoint","set",":",">",">",">","disjoint_set.subsets","(",")","[","{","1",",","2","}",",","{","'","a","'",",","3",",","'","b","'","}","]"]
docstr: Merge the subsets of `x` and `y`.
  
  The smaller subset (the child) is merged into the larger subset (the
  parent). If the subsets are of equal size, the root element which was
  first inserted into the disjoint set is selected as the parent.
  
  Parameters
  ----------
  x, y : hashable object
      Elements to merge.
  
  Returns
  -------
  merged : bool
      True if `x` and `y` were in disjoint sets, False otherwise.
docstr_tok: ["Merge","the","subsets","of","`","x","`","and","`","y","`",".","The","smaller","subset","(","the","child",")","is","merged","into","the","larger","subset","(","the","parent",")",".","If","the","subsets","are","of","equal","size",",","the","root","element","which","was","first","inserted","into","the","disjoint","set","is","selected","as","the","parent",".","Parameters","--","--","--","--","--","x",",","y",":","hashable","object","Elements","to","merge",".","Returns","--","--","--","-","merged",":","bool","True","if","`","x","`","and","`","y","`","were","in","disjoint","sets",",","False","otherwise","."]
code: def merge(self, x, y):
      """Merge the subsets of `x` and `y`.
  
      The smaller subset (the child) is merged into the larger subset (the
      parent). If the subsets are of equal size, the root element which was
      first inserted into the disjoint set is selected as the parent.
  
      Parameters
      ----------
      x, y : hashable object
          Elements to merge.
  
      Returns
      -------
      merged : bool
          True if `x` and `y` were in disjoint sets, False otherwise.
      """
      xr = self[x]
      yr = self[y]
      if self._indices[xr] == self._indices[yr]:
          return False
  
      sizes = self._sizes
      if (sizes[xr], self._indices[yr]) < (
          sizes[yr],
          self._indices[xr],
      ):
          xr, yr = yr, xr
      self._parents[yr] = xr
      self._sizes[xr] += self._sizes[yr]
      self._nbrs[xr], self._nbrs[yr] = self._nbrs[yr], self._nbrs[xr]
      self.n_subsets -= 1
      return True
  
file_path: catboost/contrib/python/scipy/py3/scipy/_lib/_disjoint_set.py
label_desc: Use image node_id 7 for calling the DisjointSet obj's underlying member method code with example usage: obj.merge(x, y) and returns: True, False