class_docstr: The Prufer correspondence is an algorithm that describes the
  bijection between labeled trees and the Prufer code. A Prufer
  code of a labeled tree is unique up to isomorphism and has
  a length of n - 2.
  
  Prufer sequences were first used by Heinz Prufer to give a
  proof of Cayley's formula.
  
  References
  ==========
  
  .. [1] https://mathworld.wolfram.com/LabeledTree.html
class_docstr_tok: ["The","Prufer","correspondence","is","an","algorithm","that","describes","the","bijection","between","labeled","trees","and","the","Prufer","code",".","A","Prufer","code","of","a","labeled","tree","is","unique","up","to","isomorphism","and","has","a","length","of","n","-","2",".","Prufer","sequences","were","first","used","by","Heinz","Prufer","to","give","a","proof","of","Cayley","'s","formula",".","References","==========","..","[","1","]","https",":","\/\/mathworld.wolfram.com\/LabeledTree.html"]
docstr: The constructor for the Prufer object.
  
  Examples
  ========
  
  >>> from sympy.combinatorics.prufer import Prufer
  
  A Prufer object can be constructed from a list of edges:
  
  >>> a = Prufer([[0, 1], [0, 2], [0, 3]])
  >>> a.prufer_repr
  [0, 0]
  
  If the number of nodes is given, no checking of the nodes will
  be performed; it will be assumed that nodes 0 through n - 1 are
  present:
  
  >>> Prufer([[0, 1], [0, 2], [0, 3]], 4)
  Prufer([[0, 1], [0, 2], [0, 3]], 4)
  
  A Prufer object can be constructed from a Prufer sequence:
  
  >>> b = Prufer([1, 3])
  >>> b.tree_repr
  [[0, 1], [1, 3], [2, 3]]
docstr_tok: ["The","constructor","for","the","Prufer","object",".","Examples","========",">",">",">","from","sympy.combinatorics.prufer","import","Prufer","A","Prufer","object","can","be","constructed","from","a","list","of","edges",":",">",">",">","a","=","Prufer","(","[","[","0",",","1","]",",","[","0",",","2","]",",","[","0",",","3","]","]",")",">",">",">","a.prufer_repr","[","0",",","0","]","If","the","number","of","nodes","is","given",",","no","checking","of","the","nodes","will","be","performed",";","it","will","be","assumed","that","nodes","0","through","n","-","1","are","present",":",">",">",">","Prufer","(","[","[","0",",","1","]",",","[","0",",","2","]",",","[","0",",","3","]","]",",","4",")","Prufer","(","[","[","0",",","1","]",",","[","0",",","2","]",",","[","0",",","3","]","]",",","4",")","A","Prufer","object","can","be","constructed","from","a","Prufer","sequence",":",">",">",">","b","=","Prufer","(","[","1",",","3","]",")",">",">",">","b.tree_repr","[","[","0",",","1","]",",","[","1",",","3","]",",","[","2",",","3","]","]"]
code: def __new__(cls, *args, **kw_args):
      """The constructor for the Prufer object.
  
      Examples
      ========
  
      >>> from sympy.combinatorics.prufer import Prufer
  
      A Prufer object can be constructed from a list of edges:
  
      >>> a = Prufer([[0, 1], [0, 2], [0, 3]])
      >>> a.prufer_repr
      [0, 0]
  
      If the number of nodes is given, no checking of the nodes will
      be performed; it will be assumed that nodes 0 through n - 1 are
      present:
  
      >>> Prufer([[0, 1], [0, 2], [0, 3]], 4)
      Prufer([[0, 1], [0, 2], [0, 3]], 4)
  
      A Prufer object can be constructed from a Prufer sequence:
  
      >>> b = Prufer([1, 3])
      >>> b.tree_repr
      [[0, 1], [1, 3], [2, 3]]
  
      """
      arg0 = Array(args[0]) if args[0] else Tuple()
      args = (arg0,) + tuple(_sympify(arg) for arg in args[1:])
      ret_obj = Basic.__new__(cls, *args, **kw_args)
      args = [list(args[0])]
      if args[0] and iterable(args[0][0]):
          if not args[0][0]:
              raise ValueError(
                  "Prufer expects at least one edge in the tree."
              )
          if len(args) > 1:
              nnodes = args[1]
          else:
              nodes = set(flatten(args[0]))
              nnodes = max(nodes) + 1
              if nnodes != len(nodes):
                  missing = set(range(nnodes)) - nodes
                  if len(missing) == 1:
                      msg = "Node %s is missing." % missing.pop()
                  else:
                      msg = "Nodes %s are missing." % sorted(missing)
                  raise ValueError(msg)
          ret_obj._tree_repr = [list(i) for i in args[0]]
          ret_obj._nodes = nnodes
      else:
          ret_obj._prufer_repr = args[0]
          ret_obj._nodes = len(ret_obj._prufer_repr) + 2
      return ret_obj
  
imports: from sympy.core import Basic
  from sympy.core.containers import Tuple
  from sympy.tensor.array import Array
  from sympy.core.sympify import _sympify
  from sympy.utilities.iterables import flatten, iterable
  from sympy.utilities.misc import as_int
  from collections import defaultdict
label_desc: Use image node_id 11 for calling the Prufer obj's underlying member method code with example usage: obj.__new__(cls) and returns: ret_obj