class_docstr: Properties
  ==========
  
  [1] `0 \in \Omega` and `\tau(1) = \epsilon`
  [2] `\alpha^x = \beta \Leftrightarrow \beta^{x^{-1}} = \alpha`
  [3] If `\alpha^x = \beta`, then `H \tau(\alpha)x = H \tau(\beta)`
  [4] `\forall \alpha \in \Omega, 1^{\tau(\alpha)} = \alpha`
  
  References
  ==========
  
  .. [1] Holt, D., Eick, B., O'Brien, E.
         "Handbook of Computational Group Theory"
  
  .. [2] John J. Cannon; Lucien A. Dimino; George Havas; Jane M. Watson
         Mathematics of Computation, Vol. 27, No. 123. (Jul., 1973), pp. 463-490.
         "Implementation and Analysis of the Todd-Coxeter Algorithm"
class_docstr_tok: ["Properties","==========","[","1","]","`","0","\\in","\\Omega","`","and","`","\\tau","(","1",")","=","\\epsilon","`","[","2","]","`","\\alpha^x","=","\\beta","\\Leftrightarrow","\\beta^","{","x^","{","-1","}","}","=","\\alpha","`","[","3","]","If","`","\\alpha^x","=","\\beta","`",",","then","`","H","\\tau","(","\\alpha",")","x","=","H","\\tau","(","\\beta",")","`","[","4","]","`","\\forall","\\alpha","\\in","\\Omega",",","1^","{","\\tau","(","\\alpha",")","}","=","\\alpha","`","References","==========","..","[","1","]","Holt",",","D.",",","Eick",",","B.",",","O'Brien",",","E.","``","Handbook","of","Computational","Group","Theory","''","..","[","2","]","John","J.","Cannon",";","Lucien","A.","Dimino",";","George","Havas",";","Jane","M.","Watson","Mathematics","of","Computation",",","Vol",".","27",",","No",".","123",".","(","Jul.",",","1973",")",",","pp",".","463-490",".","``","Implementation","and","Analysis","of","the","Todd-Coxeter","Algorithm","''"]
docstr: Merge two classes with representatives ``k`` and ``lamda``, described
  on Pg. 157 [1] (for pseudocode), start by putting ``p[k] = lamda``.
  It is more efficient to choose the new representative from the larger
  of the two classes being merged, i.e larger among ``k`` and ``lamda``.
  procedure ``merge`` performs the merging operation, adds the deleted
  class representative to the queue ``q``.
  
  Parameters
  ==========
  
  'k', 'lamda' being the two class representatives to be merged.
  
  Notes
  =====
  
  Pg. 86-87 [1] contains a description of this method.
  
  See Also
  ========
  
  coincidence, rep
docstr_tok: ["Merge","two","classes","with","representatives","``","k","``","and","``","lamda","``",",","described","on","Pg",".","157","[","1","]","(","for","pseudocode",")",",","start","by","putting","``","p","[","k","]","=","lamda","``",".","It","is","more","efficient","to","choose","the","new","representative","from","the","larger","of","the","two","classes","being","merged",",","i.e","larger","among","``","k","``","and","``","lamda","``",".","procedure","``","merge","``","performs","the","merging","operation",",","adds","the","deleted","class","representative","to","the","queue","``","q","``",".","Parameters","==========","'","k","'",",","'lamda","'","being","the","two","class","representatives","to","be","merged",".","Notes","=====","Pg",".","86-87","[","1","]","contains","a","description","of","this","method",".","See","Also","========","coincidence",",","rep"]
code: def merge(self, k, lamda, q, w=None, modified=False):
      """
      Merge two classes with representatives ``k`` and ``lamda``, described
      on Pg. 157 [1] (for pseudocode), start by putting ``p[k] = lamda``.
      It is more efficient to choose the new representative from the larger
      of the two classes being merged, i.e larger among ``k`` and ``lamda``.
      procedure ``merge`` performs the merging operation, adds the deleted
      class representative to the queue ``q``.
  
      Parameters
      ==========
  
      'k', 'lamda' being the two class representatives to be merged.
  
      Notes
      =====
  
      Pg. 86-87 [1] contains a description of this method.
  
      See Also
      ========
  
      coincidence, rep
  
      """
      p = self.p
      rep = self.rep
      phi = rep(k, modified=modified)
      psi = rep(lamda, modified=modified)
      if phi != psi:
          mu = min(phi, psi)
          v = max(phi, psi)
          p[v] = mu
          if modified:
              if v == phi:
                  self.p_p[phi] = (
                      self.p_p[k] ** -1 * w * self.p_p[lamda]
                  )
              else:
                  self.p_p[psi] = (
                      self.p_p[lamda] ** -1 * w**-1 * self.p_p[k]
                  )
          q.append(v)
  
imports: from sympy.combinatorics.free_groups import free_group
  from sympy.printing.defaults import DefaultPrinting
  from itertools import chain, product
  from bisect import bisect_left
label_desc: Use image node_id 13 for calling the CosetTable obj's underlying member method code with example usage: obj.merge(k, lamda, q, w, modified) without return types