+
    �°³j  ã                   óà   € R t RR.t^ RIHt ^ RIt]P                  ! RRR7      R 4       t]P                  ! RR7      R	 4       t]! R4      R
 4       t	]! R4      R 4       t
RR ltR tR tR tR# )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)Ú	lru_cacheNT)ÚgraphsÚreturns_graphc              #  óx  "  € V ^ 8  d   \        R4      hV ^ 8X  d   R# V ^8X  d   \        P                  ! ^4      x € R# \        \	        V ^,          ^,           4      4      \        \	        ^V ^,           ^,          4      4      ,           pVe,   \        V4      pVf   K  \        V4      x € \        V4      pK/  R# 5i)a|  Generate nonisomorphic trees of specified `order`.

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

Yields
------
`networkx.Graph` instances
   A tree with `order` number of nodes that is not isomorphic to any other
   yielded tree.

Raises
------
ValueError
   If `order` is negative.

Examples
--------
There are 11 unique (non-isomorphic) trees with 7 nodes.

>>> n = 7
>>> nit_list = list(nx.nonisomorphic_trees(n))
>>> len(nit_list) == nx.number_of_nonisomorphic_trees(n) == 11
True

All trees yielded by the generator have the specified order.

>>> all(len(G) == n for G in nx.nonisomorphic_trees(n))
True

Each tree is nonisomorphic to every other tree yielded by the generator.
>>> seen = []
>>> for G in nx.nonisomorphic_trees(n):
...     assert not any(nx.is_isomorphic(G, H) for H in seen)
...     seen.append(G)

See Also
--------
number_of_nonisomorphic_trees
úorder must be non-negativeN)Ú
ValueErrorÚnxÚempty_graphÚlistÚrangeÚ
_next_treeÚ_layout_to_graphÚ_next_rooted_tree)ÚorderÚlayouts   & Úh/home/luca/screen-checking/.venv/lib/python3.14/site-packages/networkx/generators/nonisomorphic_trees.pyr   r      sŸ   é € ðX ˆq„yÜÐ5Ó6Ð6Ø�„záà�„zÜ�nŠn˜QÓÒÙä”%˜ �
 Q�Ó'Ó(¬4´°a¸%À!½)ÈÕ9IÓ0JÓ+KÕK€Fà
Ò
Ü˜FÓ#ˆØÔÜ" 6Ó*Ò*Ü& vÓ.ŠFñ	 ùs   ‚BB:ÂB:)r   c                ó<   € V ^ 8  d   \        R4      h\        V 4      # )aó  Returns the number of nonisomorphic trees of the specified `order`.

Based on an algorithm by Alois P. Heinz in
`OEIS entry A000055 <https://oeis.org/A000055>`_. Complexity is ``O(n ** 3)``.

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

Returns
-------
int
   Number of nonisomorphic trees with `order` number of nodes.

Raises
------
ValueError
   If `order` is negative.

Examples
--------
>>> nx.number_of_nonisomorphic_trees(10)
106

See Also
--------
nonisomorphic_trees
r   )r	   Ú_unlabeled_trees)r   s   &r   r   r   P   s"   € ð> ˆq„yÜÐ5Ó6Ð6Ü˜EÓ"Ð"ó    c                ó  € ^ p\        V ^,           4       F+  pV\        V4      \        W,
          4      ,          ,          pK-  	  V ^,          ^ 8X  d   V\        V ^,          4      ,          p\        V 4      V^,          ,
          # )z4Implements OEIS A000055 (number of unlabeled trees).©r   Ú_rooted_trees)ÚnÚvalueÚks   &  r   r   r   t   sh   € ð €EÜ�1�q•5Ž\ˆØ”˜qÓ!¤M°!µ%Ó$8Õ8Õ8Šñ àˆ1…u�„zØ”˜q A�vÓ&Õ&ˆÜ˜Ó˜e q�jÕ(Ð(r   c                óü   € V ^8  d   V # ^ p\        ^V 4       FS  p\        ^V 4       F@  pW#,          ^ 8X  g   K  W\        V4      ,          \        W,
          4      ,          ,          pKB  	  KU  	  W^,
          ,          # )z;Implements OEIS A000081 (number of unlabeled rooted trees).r   )r   r   ÚjÚds   &   r   r   r   €   sk   € ð 	ˆ1„uØˆØ€EÜ�1�aŽ[ˆÜ�q˜!–ˆAØ�u˜ŽzØœ]¨1Ó-Õ-´¸a½eÓ0DÕDÕD’ó ñ ð ˜•UÕÐr   c                óN  € Vf+   \        V 4      ^,
          pW,          ^8X  d   V^,          pK  V^ 8X  d   R# V^,
          pW,          W,          ^,
          8w  d   V^,          pK%  \        V 4      p\        V\        V4      4       F  pW4V,
          V,           ,          W4&   K  	  V# )z0One iteration of the Beyer-Hedetniemi algorithm.N)Úlenr   r   )ÚpredecessorÚpÚqÚresultÚis   &&   r   r   r   Ž   sŽ   € ð 	‚yÜ�Ó˜qÕ ˆØ�n Ô!Ø��FŠAØˆA„vÙà	ˆA�€AØ
�.˜K�N¨QÕ.Ô
.Ø	ˆQ�ŠÜ�+Ó€FÜ�1”c˜&“kÖ"ˆØ˜q�5 1�9Õ%ˆ‹	ñ #à€Mr   c                ó¶  € \        V 4      w  r\        V4      p\        V4      pWC8¬  pV'       dD   WC8X  d>   \        V4      \        V4      8”  d   RpM!\        V4      \        V4      8X  d	   W8”  d   RpV'       d   V # \        V4      p\        W4      pW,          ^8”  d:   \        V4      w  r‰\        V4      p
\	        ^V
^,           4      pW·\        V4      ) R% V# )zCOne iteration of the Wright, Richmond, Odlyzko and McKay
algorithm.FN)Ú_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   ¡   sË   € ô ˜YÓ'�J€Dô �d“)€KÜ�d“)€KØÑ&€Eç�Ô+ô ˆt‹9”s˜4“yÔ Ø‰Eô �‹Yœ#˜d›)Ô#¨¬ØˆEçØÐô �‹IˆÜ)¨)Ó7ˆØ�<˜!ÔÜ!,¨]Ó!;ÑˆHÜ! (›mˆOÜ˜1˜o°Õ1Ó2ˆFØ,2œ3˜v›;˜,˜.Ð)ØÐr   c                óh  € RpRp\        \        V 4      4       F   pW,          ^8X  g   K  V'       d   Tp MRpK"  	  Vf   \        V 4      p\        ^V4       Uu. uF  q0V,          ^,
          NK  	  pp^ .\        V\        V 4      4       Uu. uF  q0V,          NK  	  up,           pWE3# u upi u upi )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.FNT)r   r!   )r   Ú	one_foundÚmr&   r+   r,   s   &     r   r(   r(   È   s¨   € ð
 €IØ€AÜ”3�v“;ÖˆØ�9˜Ž>ßØ�Ùà ’	ñ  ð 	‚yÜ�‹Kˆä#(¨¨A¤;Ó/¡;˜a�1�I˜�MˆM¡;€DÐ/Øˆ3¤U¨1¬c°&«kÔ%:Ó;Ñ%: ˜—)�)Ñ%:Ñ;Õ;€DØˆ<Ðùò 0ùÚ;s   ÁB*ÂB/c                óB  € \         P                  ! 4       p. p\        \        V 4      4       Fo  pW,          pV'       dL   VR,          pW,          pWd8¼  d$   VP	                  4        VR,          pW,          pK)  VP                  W54       VP                  V4       Kq  	  V# )zRCreate a NetworkX Graph for the tree specified by the
given layout(level sequence)éÿÿÿÿ)r
   ÚGraphr   r!   ÚpopÚadd_edgeÚappend)r   ÚGÚstackr&   Úi_levelr   Új_levels   &      r   r   r   ß   s~   € ô 	�Š‹
€AØ€EÜ”3�v“;ÖˆØ•)ˆßØ�b•	ˆAØ•iˆGØÔ$Ø—	‘	”Ø˜"•I�Ø �)’Ø�J‰J�qÔØ�‰�QŽñ  ð €Hr   )N)Ú__doc__Ú__all__Ú	functoolsr   Únetworkxr
   Ú_dispatchabler   r   r   r   r   r   r(   r   © r   r   Ú<module>rH      s¤   ðñð !Ð"AÐ
B€å ã ð ×Ò˜¨TÔ2ñ;/ó 3ð;/ð| ×Ò˜Ôñ #ó ð #ñF ˆ4ƒñ)ó ð)ñ ˆ4ƒñ
ó ð
ôò&$òNô.r   