
    Pi                         d dl Z d dlZd dlmc mZ d dlmZ	  G d d          Z
 G d d          Z G d d          ZdS )    Nc                      e Zd Zej                            dg d          d             Zej                            d ed                    d             Zej                            d ed                    d             Z	d	 Z
d
 Zej                            dej        ej        ej        g          d             ZdS )TestKFactorn)         c                     t          j        |          }t          j        |d          }|j        |j        k    sJ |j        |j        k    sJ d S )N   )nxcycle_graphk_factoredgesnodes)selfr   gkfs       z/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/networkx/algorithms/tests/test_regular.pytest_k_factor_cyclezTestKFactor.test_k_factor_cycle	   sR    N1[Aw"(""""w"(""""""    kr   c                     t          j        dd          t          j        |          }j        |j        k    sJ t	          fd|j        D                       sJ t          j        ||          sJ d S )Nr   c              3   ,   K   | ]} j         | V  d S Nhas_edge.0er   s     r   	<genexpr>z1TestKFactor.test_k_factor_grid.<locals>.<genexpr>   +      44a:1:q>444444r   )r   grid_2d_graphr   r   allr   is_k_regularr   r   r   r   s      @r   test_k_factor_gridzTestKFactor.test_k_factor_grid   s    Q""[Aw"(""""44442844444444r1%%%%%%%r      c                     t          j        d          t          j        |          }j        |j        k    sJ t	          fd|j        D                       sJ t          j        ||          sJ d S )Nr&   c              3   ,   K   | ]} j         | V  d S r   r   r   s     r   r   z5TestKFactor.test_k_factor_complete.<locals>.<genexpr>   r    r   )r   complete_graphr   r   r"   r   r#   r$   s      @r   test_k_factor_completez"TestKFactor.test_k_factor_complete   s    a  [Aw"(""""44442844444444r1%%%%%%%r   c                     t          j        dd          }t          j        t           j        d          5  t          j        |d           d d d            d S # 1 swxY w Y   d S )Nr   zdegree less thanmatchr   )r   r!   pytestraisesNetworkXUnfeasibler   r   r   s     r   test_k_factor_degreez TestKFactor.test_k_factor_degree    s    Q""]208KLLL 	 	K1	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   AA Ac                     t          j        dd          }t          j        t           j        d          5  t          j        |d           d d d            d S # 1 swxY w Y   d S )Nr   zno perfect matchingr,   r
   )r   hexagonal_lattice_graphr.   r/   r0   r   r1   s     r   test_k_factor_no_matchingz%TestKFactor.test_k_factor_no_matching%   s    &q!,,]208NOOO 	 	K1	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r3   
graph_typec                     t          j        t          j        d          5  t          j         |            d           d d d            d S # 1 swxY w Y   d S )Nznot implemented forr,   r
   )r.   r/   r   NetworkXNotImplementedr   )r   r7   s     r   test_k_factor_not_implementedz)TestKFactor.test_k_factor_not_implemented+   s    ]24<RSSS 	) 	)K

a(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   AAAN)__name__
__module____qualname__r.   markparametrizer   ranger%   r*   r2   r6   r   DiGraph
MultiGraphMultiDiGraphr:    r   r   r   r      s
       [S))),,# # -,# [S%%((++& & ,+& [S%%((++& & ,+&  
   [\BJr+WXX) ) YX) ) )r   r   c                      e Zd Zej                            d ej        d          df ej        d          df ej	        d          df ej
        dd          df ej        dej                  df ej        dg          df ej        dg          df ej        ddg          df ej        ddg          dfg	          d	             Zd
 ZdS )TestIsRegularzgraph,expectedr   Tr   Fr   )create_using)r      c                 :    t          j        |          |k    sJ d S r   )reg
is_regular)r   graphexpecteds      r   test_is_regularzTestIsRegular.test_is_regular2   s%     ~e$$000000r   c                     t          j                    }t          j        t           j        d          5  t          j        |           d d d            d S # 1 swxY w Y   d S )NzGraph has no nodesr,   )r   Graphr.   r/   NetworkXPointlessConceptrK   )r   Gs     r   "test_is_regular_empty_graph_raisesz0TestIsRegular.test_is_regular_empty_graph_raisesC   s    HJJ]26>RSSS 	 	M!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   AAAN)r;   r<   r=   r.   r>   r?   r   r   r)   
path_graphlollipop_graphrA   rP   rB   rC   rN   rS   rD   r   r   rF   rF   1   s&       [R^A%Rq!!4(R]1u%Rq!$$e,R^ABJ777>RXvh&RZ!!5)R]FF+,,d3R_ff-..6
	
 1 1 1    r   rF   c                        e Zd Zd Zd Zd ZdS )TestIsKRegularc                     t          j        d          }t          j        |d          sJ t          j        |d          rJ d S )Nr   r
   r   )genr   rJ   r#   r1   s     r   test_is_k_regular1z!TestIsKRegular.test_is_k_regular1J   sI    OA1%%%%%#Aq)))))))r   c                     t          j        d          }t          j        |d          sJ t          j        |d          rJ t          j        |d          rJ d S )Nr   r   r   r&   )rY   r)   rJ   r#   r1   s     r   test_is_k_regular2z!TestIsKRegular.test_is_k_regular2O   sc    q!!1%%%%%#Aq)))))#Aq)))))))r   c                     t          j        dd          }t          j        |d          rJ t          j        |d          rJ d S )Nr   r&   )rY   rU   rJ   r#   r1   s     r   test_is_k_regular3z!TestIsKRegular.test_is_k_regular3U   sL    q!$$#Aq)))))#Aq)))))))r   N)r;   r<   r=   rZ   r\   r^   rD   r   r   rW   rW   I   sA        * * *
* * ** * * * *r   rW   )r.   networkxr   networkx.algorithms.regular
algorithmsregularrJ   networkx.generators
generatorsrY   r   rF   rW   rD   r   r   <module>re      s         ) ) ) ) ) ) ) ) ) ! ! ! ! ! !&) &) &) &) &) &) &) &)R       0* * * * * * * * * *r   