
    ܛ7i                     n    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y)    Nc                      e Zd Zej                  j                  dg d      d        Zej                  j                  d ed            d        Zej                  j                  d ed            d        Z	d	 Z
d
 Zej                  j                  dej                  ej                  ej                  g      d        Zy)TestKFactorn)         c                     t        j                  |      }t        j                  |d      }|j                  |j                  k(  sJ |j                  |j                  k(  sJ y )N   )nxcycle_graphk_factoredgesnodes)selfr   gkfs       c/home/rose/Desktop/poly/venv/lib/python3.12/site-packages/networkx/algorithms/tests/test_regular.pytest_k_factor_cyclezTestKFactor.test_k_factor_cycle	   sL    NN1[[Aww"(("""ww"(("""    kr   c                    t        j                  dd      t        j                  |      }j                  |j                  k(  sJ t	        fd|j
                  D              sJ t        j                  ||      sJ y )Nr   c              3   <   K   | ]  } j                   |   y wNhas_edge.0er   s     r   	<genexpr>z1TestKFactor.test_k_factor_grid.<locals>.<genexpr>        48a:1::q>8   )r   grid_2d_graphr   r   allr   is_k_regularr   r   r   r   s      @r   test_k_factor_gridzTestKFactor.test_k_factor_grid   sg    Q"[[Aww"(("""4288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 y )Nr'   c              3   <   K   | ]  } j                   |   y w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   se    a [[Aww"(("""42884444r1%%%r   c                     t        j                  dd      }t        j                  t         j                  d      5  t        j
                  |d       d d d        y # 1 sw Y   y xY w)Nr   zdegree less thanmatchr   )r   r"   pytestraisesNetworkXUnfeasibler   r   r   s     r   test_k_factor_degreez TestKFactor.test_k_factor_degree    sD    Q"]]2008KLKK1 MLL   AA%c                     t        j                  dd      }t        j                  t         j                  d      5  t        j
                  |d       d d d        y # 1 sw Y   y xY w)Nr   zno perfect matchingr-   r
   )r   hexagonal_lattice_graphr/   r0   r1   r   r2   s     r   test_k_factor_no_matchingz%TestKFactor.test_k_factor_no_matching%   sD    &&q!,]]2008NOKK1 POOr4   
graph_typec                     t        j                  t        j                  d      5  t        j                   |       d       d d d        y # 1 sw Y   y xY w)Nznot implemented forr-   r
   )r/   r0   r   NetworkXNotImplementedr   )r   r8   s     r   test_k_factor_not_implementedz)TestKFactor.test_k_factor_not_implemented+   s4    ]]244<RSKK
a( TSSs   AAN)__name__
__module____qualname__r/   markparametrizer   ranger&   r+   r3   r7   r   DiGraph
MultiGraphMultiDiGraphr;    r   r   r   r      s    [[S),# -# [[S%(+& ,& [[S%(+& ,&
 [[\BJJr+WX) Y)r   r   c                      e Zd Zej                  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y)TestIsRegularzgraph,expectedr   Tr   Fr   )create_using)r      c                 8    t        j                  |      |k(  sJ y r   )reg
is_regular)r   graphexpecteds      r   test_is_regularzTestIsRegular.test_is_regular2   s     ~~e$000r   c                     t        j                         }t        j                  t         j                  d      5  t        j
                  |       d d d        y # 1 sw Y   y xY w)NzGraph has no nodesr-   )r   Graphr/   r0   NetworkXPointlessConceptrL   )r   Gs     r   "test_is_regular_empty_graph_raisesz0TestIsRegular.test_is_regular_empty_graph_raisesC   s;    HHJ]]266>RSMM! TSSs   AA"N)r<   r=   r>   r/   r?   r@   r   r   r*   
path_graphlollipop_graphrB   rQ   rC   rD   rO   rT   rE   r   r   rG   rG   1   s    [[R^^A%Rq!4(R]]1u%Rq!$e,R^^ABJJ7>RXXvh&RZZ!5)R]]FF+,d3R__ff-.6
	
11r   rG   c                       e Zd Zd Zd Zd Zy)TestIsKRegularc                     t        j                  d      }t        j                  |d      sJ t        j                  |d      rJ y )Nr   r
   r   )genr   rK   r$   r2   s     r   test_is_k_regular1z!TestIsKRegular.test_is_k_regular1J   s?    OOA1%%%##Aq))))r   c                     t        j                  d      }t        j                  |d      sJ t        j                  |d      rJ t        j                  |d      rJ y )Nr   r   r   r'   )rZ   r*   rK   r$   r2   s     r   test_is_k_regular2z!TestIsKRegular.test_is_k_regular2O   sW    q!1%%%##Aq)))##Aq))))r   c                     t        j                  dd      }t        j                  |d      rJ t        j                  |d      rJ y )Nr   r'   )rZ   rV   rK   r$   r2   s     r   test_is_k_regular3z!TestIsKRegular.test_is_k_regular3U   sC    q!$##Aq)))##Aq))))r   N)r<   r=   r>   r[   r]   r_   rE   r   r   rX   rX   I   s    *
**r   rX   )r/   networkxr   networkx.algorithms.regular
algorithmsregularrK   networkx.generators
generatorsrZ   r   rG   rX   rE   r   r   <module>rf      s3      ) ) !&) &)R 0* *r   