Ë
    D^(h5  ã                   ó    — d Z ddgZddlZ ej                  dd¬«      dd„«       Z ej                  d¬«      d	„ «       Zdd
„Zd„ Zd„ Z	d„ Z
d„ Zy)a  
Implementation of the Wright, Richmond, Odlyzko and McKay (WROM)
algorithm for the enumeration of all non-isomorphic free trees of a
given order.  Rooted trees are represented by level sequences, i.e.,
lists in which the i-th element specifies the distance of vertex i to
the root.

Únonisomorphic_treesÚnumber_of_nonisomorphic_treesé    NT)ÚgraphsÚreturns_graphc              #   óL  K  — | dk  rt         ‚t        t        | dz  dz   «      «      t        t        d| dz   dz  «      «      z   }|�]t        |«      }|�L|dk(  rt	        |«      –— n.|dk(  r)ddl}|j                  dt        d¬«       t        |«      –— t        |«      }|�Œ\yy­w)	a  Generates lists of nonisomorphic trees

    Parameters
    ----------
    order : int
       order of the desired tree(s)

    create : one of {"graph", "matrix"} (default="graph")
       If ``"graph"`` is selected a list of ``Graph`` instances will be returned,
       if matrix is selected a list of adjacency matrices will be returned.

       .. deprecated:: 3.3

          The `create` argument is deprecated and will be removed in NetworkX
          version 3.5. In the future, `nonisomorphic_trees` will yield graph
          instances by default. To generate adjacency matrices, call
          ``nx.to_numpy_array`` on the output, e.g.::

             [nx.to_numpy_array(G) for G in nx.nonisomorphic_trees(N)]

    Yields
    ------
    list
       A list of nonisomorphic trees, in one of two formats depending on the
       value of the `create` parameter:
       - ``create="graph"``: yields a list of `networkx.Graph` instances
       - ``create="matrix"``: yields a list of list-of-lists representing adjacency matrices
    é   é   NÚgraphÚmatrixr   zï

The 'create=matrix' argument of nonisomorphic_trees
is deprecated and will be removed in version 3.5.
Use ``nx.to_numpy_array`` to convert graphs to adjacency matrices, e.g.::

   [nx.to_numpy_array(G) for G in nx.nonisomorphic_trees(N)])ÚcategoryÚ
stacklevel)
Ú
ValueErrorÚlistÚrangeÚ
_next_treeÚ_layout_to_graphÚwarningsÚwarnÚDeprecationWarningÚ_layout_to_matrixÚ_next_rooted_tree)ÚorderÚcreateÚlayoutr   s       úe/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/networkx/generators/nonisomorphic_trees.pyr   r      s¸   è ø€ ð> ˆq‚yÜÐä”%˜ ™
 Q™Ó'Ó(¬4´°a¸%À!¹)ÈÑ9IÓ0JÓ+KÑK€Fà
Ð
Ü˜FÓ#ˆØÐØ˜Ò Ü& vÓ.Ó.Ø˜8Ò#Ûà—‘ðWô 0Ø ð ô 
ô (¨Ó/Ò/Ü& vÓ.ˆFð+ Ó
ùs   ‚BB$Â"B$)r   c                 ó8   — t        d„ t        | «      D «       «      S )zùReturns the number of nonisomorphic trees

    Parameters
    ----------
    order : int
      order of the desired tree(s)

    Returns
    -------
    length : Number of nonisomorphic graphs for the given order

    References
    ----------

    c              3   ó    K  — | ]  }d –— Œ y­w)r	   N© )Ú.0Ú_s     r   ú	<genexpr>z0number_of_nonisomorphic_trees.<locals>.<genexpr>\   s   è ø€ Ò5�QŒqÑ5ùs   ‚)Úsumr   )r   s    r   r   r   K   s   € ô" Ñ5Ô-¨eÓ4Ô5Ó5Ð5ó    c                 ó  — |€$t        | «      dz
  }| |   dk(  r|dz  }| |   dk(  rŒ|dk(  ry|dz
  }| |   | |   dz
  k7  r|dz  }| |   | |   dz
  k7  rŒt        | «      }t        |t        |«      «      D ]  }|||z
  |z      ||<   Œ |S )z0One iteration of the Beyer-Hedetniemi algorithm.Nr	   r   )Úlenr   r   )ÚpredecessorÚpÚqÚresultÚis        r   r   r   _   sÂ   € ð 	€yÜ�Ó˜qÑ ˆØ˜!‰n Ò!Ø�‰FˆAð ˜!‰n Ó!àˆA‚vØà	ˆA‰€AØ
�a‰.˜K¨™N¨QÑ.Ò
.Ø	ˆQ‰ˆð �a‰.˜K¨™N¨QÑ.Ó
.ä�+Ó€FÜ�1”c˜&“kÓ"ò &ˆØ˜1˜q™5 1™9Ñ%ˆˆqŠ	ð&à€Mr#   c                 óŠ  — t        | «      \  }}t        |«      }t        |«      }||k\  }|r=||k(  r8t        |«      t        |«      kD  rd}nt        |«      t        |«      k(  r||kD  rd}|r| S t        |«      }t        | |«      }| |   dkD  r7t        |«      \  }}	t        |«      }
t	        d|
dz   «      }||t        |«       d |S )zGOne iteration of the Wright, Richmond, Odlyzko and McKay
    algorithm.Fr   r	   N)Ú_split_treeÚmaxr%   r   r   )Ú	candidateÚleftÚrestÚleft_heightÚrest_heightÚvalidr'   Únew_candidateÚnew_leftÚnew_restÚnew_left_heightÚsuffixs               r   r   r   r   sÛ   € ô ˜YÓ'�J€Dˆ$ô �d“)€KÜ�d“)€KØ˜;Ñ&€Eá� Ò+ô ˆt‹9”s˜4“yÒ Ø‰Eô �‹Yœ#˜d›)Ò#¨¨tªØˆEáØÐô �‹IˆÜ)¨)°QÓ7ˆØ�Q‰<˜!ÒÜ!,¨]Ó!;ÑˆH�hÜ! (›mˆOÜ˜1˜o°Ñ1Ó2ˆFØ,2ˆMœ3˜v›;˜,˜.Ð)ØÐr#   c                 ó&  — d}d}t        t        | «      «      D ]  }| |   dk(  sŒ|r|} nd}Œ |€t        | «      }t        d|«      D �cg c]
  }| |   dz
  ‘Œ }}dgt        |t        | «      «      D �cg c]  }| |   ‘Œ	 c}z   }||fS c c}w c c}w )zŸReturns a tuple of two layouts, one containing the left
    subtree of the root vertex, and one containing the original tree
    with the left subtree removed.FNr	   Tr   )r   r%   )r   Ú	one_foundÚmr*   r/   r0   s         r   r,   r,   ™   sª   € ð
 €IØ€AÜ”3�v“;Óò !ˆØ�!‰9˜‹>ÙØ�Ùà ‘	ð!ð 	€yÜ�‹Kˆä#(¨¨A£;Ö/˜aˆF�1‰I˜‹MÐ/€DÐ/Øˆ3¤U¨1¬c°&«kÓ%:Ö; �&˜“)Ò;Ñ;€DØ�$ˆ<Ðùò 0ùÚ;s   Á
B	Á4Bc                 óP  — t        t        | «      «      D �cg c]  }dgt        | «      z  ‘Œ }}g }t        t        | «      «      D ]Y  }| |   }|r?|d   }| |   }||k\  r |j                  «        |d   }| |   }||k\  rŒ dx||   |<   ||   |<   |j                  |«       Œ[ |S c c}w )z\Create the adjacency matrix for the tree specified by the
    given layout (level sequence).r   éÿÿÿÿr	   )r   r%   ÚpopÚappend)r   r*   r)   ÚstackÚi_levelÚjÚj_levels          r   r   r   °   sÆ   € ô */¬s°6«{Ó);Ö< Aˆqˆc”C˜“KÓÐ<€FÐ<Ø€EÜ”3�v“;Óò 
ˆØ˜‘)ˆÙØ�b‘	ˆAØ˜Q‘iˆGØ˜WÒ$Ø—	‘	”Ø˜"‘I�Ø  ™)�ð ˜WÓ$ð +,Ð+ˆF�1‰I�a‰L˜6 !™9 Q™<Ø�‰�Q�ð
ð €Mùò =s   —B#c                 ó  — t        j                  «       }g }t        t        | «      «      D ][  }| |   }|rA|d   }| |   }||k\  r |j	                  «        |d   }| |   }||k\  rŒ |j                  ||«       |j                  |«       Œ] |S )zVCreate a NetworkX Graph for the tree specified by the
    given layout(level sequence)r=   )ÚnxÚGraphr   r%   r>   Úadd_edger?   )r   ÚGr@   r*   rA   rB   rC   s          r   r   r   Ä   s™   € ô 	�‰‹
€AØ€EÜ”3�v“;Óò 
ˆØ˜‘)ˆÙØ�b‘	ˆAØ˜Q‘iˆGØ˜WÒ$Ø—	‘	”Ø˜"‘I�Ø  ™)�ð ˜WÓ$ð �J‰J�q˜!ÔØ�‰�Q�ð
ð €Hr#   )r
   )N)Ú__doc__Ú__all__ÚnetworkxrE   Ú_dispatchabler   r   r   r   r,   r   r   r   r#   r   ú<module>rM      sy   ðñð !Ð"AÐ
B€ã ð €×Ñ˜¨TÔ2ò8/ó 3ð8/ðv €×Ñ˜Ôñ6ó ð6ó&ò&$òNò.ó(r#   