Ë
    D^(h  ã                   óH   — d Z ddlmZmZ ddlZddlZd„ Zd„ Z G d„ d«      Z	y)z1Unit tests for the chain decomposition functions.é    )ÚcycleÚisliceNc              #   óŠ   K  — t        | «      }t        | «      }| D ]$  }t        t        ||«      «      –— t	        |«       Œ& y­w)z§Yields cyclic permutations of the given sequence.

    For example::

        >>> list(cycles("abc"))
        [('a', 'b', 'c'), ('b', 'c', 'a'), ('c', 'a', 'b')]

    N)Úlenr   Útupler   Únext)ÚseqÚnÚ
cycled_seqÚxs       úc/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/networkx/algorithms/tests/test_chains.pyÚcyclesr   
   sC   è ø€ ô 	ˆC‹€AÜ�s“€JØò ˆÜ”F˜: qÓ)Ó*Ò*ÜˆZÕñùs   ‚AAc                 óT   ‡— t        ‰«      Št        ˆfd„t        | «      D «       «      S )zÆDecide whether two sequences are equal up to cyclic permutations.

    For example::

        >>> cyclic_equals("xyz", "zxy")
        True
        >>> cyclic_equals("xyz", "zyx")
        False

    c              3   ó:   •K  — | ]  }|t        ‰«      k(  –— Œ y ­w)N)r   )Ú.0r   Úseq2s     €r   ú	<genexpr>z cyclic_equals.<locals>.<genexpr>'   s   øè ø€ Ò6 Aˆq”E˜$“KÕÑ6ùs   ƒ)r   Úanyr   )Úseq1r   s    `r   Úcyclic_equalsr      s#   ø€ ô �‹;€DÜÓ6¬°«Ô6Ó6Ð6ó    c                   ó4   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	y)	ÚTestChainDecompositionz0Unit tests for the chain decomposition function.c                 óÞ   — t        t        |D �cg c]  }t        t        |«      «      ‘Œ c}«      «      }|D ]  }t        ||«      r y t        ||«      sŒ y  | j	                  d«       y c c}w )Nzchain not found)ÚlistÚreversedr   r   Úfail)ÚselfÚchainÚexpectedÚeÚreversed_chainÚ	candidates         r   ÚassertContainsChainz*TestChainDecomposition.assertContainsChain-   se   € ô œhÀEÖ'J¸q¬¬h°q«kÕ(:Ò'JÓKÓLˆØ!ò 	)ˆIÜ˜U IÔ.ÙÜ˜^¨YÕ7Ùð		)ð �I‰IÐ'Õ(ùò (Ks   �A*c                 óÊ   — g d¢}t        j                  |«      }g d¢ddgddgg d¢g d¢g}t        t        j                  |d	¬
«      «      }t	        |«      t	        |«      k(  sJ ‚y )N)©é   é   )r(   é   ©r)   é   )r)   é   )r,   é   )r-   é   )r.   é   )r,   é	   )r0   é
   ©r'   r)   ©r'   r+   ©r(   r,   ©r,   r1   ©r-   r/   )r2   )r)   r(   )r(   r'   r3   )r+   r)   r4   ©r,   r)   )r5   )r1   r0   )r0   r,   )r6   )r/   r.   )r.   r-   r'   ©Úroot)ÚnxÚGraphr   Úchain_decompositionr   )r   ÚedgesÚGr    Úchainss        r   Útest_decompositionz)TestChainDecomposition.test_decomposition:   sg   € ò
ˆô$ �H‰H�U‹Oˆâ$Ø�VÐØ�VÐÚ&Ú$ð
ˆô ”b×,Ñ,¨Q°QÔ7Ó8ˆÜ�6‹{œc (›mÒ+Ð+Ñ+r   c                 óä   — t        j                  dd«      }t        t        j                  |d¬«      «      }g d¢g d¢g}t	        |«      t	        |«      k(  sJ ‚|D ]  }| j                  ||«       Œ y )Nr)   r   r8   ©)r   r'   r&   )r(   r   ©r*   )r+   r,   r7   )r:   Úbarbell_graphr   r<   r   r$   )r   r>   r?   r    r   s        r   Útest_barbell_graphz)TestChainDecomposition.test_barbell_graph]   sk   € ä×Ñ˜Q Ó"ˆÜ”b×,Ñ,¨Q°QÔ7Ó8ˆÚ,Ò.FÐGˆÜ�6‹{œc (›mÒ+Ð+Ð+Øò 	6ˆEØ×$Ñ$ U¨HÕ5ñ	6r   c                 ó°  — t        j                  dd«      }t        j                  dd«      }t        t        t	        d«      d«      «      }t        j
                  ||d¬«       t        j                  ||«      }t        t        j                  |«      «      }g d¢g d¢g d	¢g d
¢g}t        |«      t        |«      k(  sJ ‚|D ]  }| j                  ||«       Œ y)z4Test for a graph with multiple connected components.r)   r   r-   ÚabcdefF©ÚcopyrB   rC   ©)ÚaÚb)rL   Úc)rM   rK   ©)Údr!   )r!   Úf)rP   rO   N©r:   rD   ÚdictÚzipÚrangeÚrelabel_nodesÚunionr   r<   r   r$   ©r   r>   ÚHÚmappingr?   r    r   s          r   Útest_disconnected_graphz.TestChainDecomposition.test_disconnected_graphf   s»   € ä×Ñ˜Q Ó"ˆÜ×Ñ˜Q Ó"ˆÜ”sœ5 ›8 XÓ.Ó/ˆÜ
×Ñ˜˜G¨%Õ0Ü�H‰H�Q˜‹NˆÜ”b×,Ñ,¨QÓ/Ó0ˆâ$Ú$Ú0Ú0ð	
ˆô �6‹{œc (›mÒ+Ð+Ð+Øò 	6ˆEØ×$Ñ$ U¨HÕ5ñ	6r   c                 ó¨  — t        j                  dd«      }t        j                  dd«      }t        t        t	        d«      d«      «      }t        j
                  ||d¬«       t        j                  ||«      }t        t        j                  |d¬«      «      }g d	¢g d
¢g}t        |«      t        |«      k(  sJ ‚|D ]  }| j                  ||«       Œ y)z4Test for a single component of a disconnected graph.r)   r   r-   rG   FrH   rK   r8   rJ   rN   NrQ   rW   s          r   Ú!test_disconnected_graph_root_nodez8TestChainDecomposition.test_disconnected_graph_root_nodex   s·   € ä×Ñ˜Q Ó"ˆÜ×Ñ˜Q Ó"ˆÜ”sœ5 ›8 XÓ.Ó/ˆÜ
×Ñ˜˜G¨%Õ0Ü�H‰H�Q˜‹NˆÜ”b×,Ñ,¨Q°SÔ9Ó:ˆâ0Ú0ð
ˆô �6‹{œc (›mÒ+Ð+Ð+Øò 	6ˆEØ×$Ñ$ U¨HÕ5ñ	6r   c                 óð   — t        j                  «       }|j                  g d¢«       t        j                  t         j
                  «      5  t        j                  |d¬«       ddd«       y# 1 sw Y   yxY w)z2Test chain decomposition when root is not in graph)r'   r(   r)   r-   r8   N)r:   r;   Úadd_nodes_fromÚpytestÚraisesÚNodeNotFoundÚhas_bridges)r   r>   s     r   Ú&test_chain_decomposition_root_not_in_Gz=TestChainDecomposition.test_chain_decomposition_root_not_in_Gˆ   sN   € ä�H‰H‹JˆØ	×ÑšÔ#Ü�]‰]œ2Ÿ?™?Ó+ñ 	&Ü�N‰N˜1 1Õ%÷	&÷ 	&ñ 	&ús   ÁA,Á,A5N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r$   r@   rE   rZ   r\   rc   © r   r   r   r   *   s$   „ Ù:ò)ò,òF6ò6ò$6ó &r   r   )
rg   Ú	itertoolsr   r   r_   Únetworkxr:   r   r   r   rh   r   r   ú<module>rk      s'   ðÙ 7ç #ã ã òò 7÷ c&ò c&r   