
    ިsgB
                     |    d dl Z 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d Z G d d      Zy)	    Nc                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)TestKFactorc                     t        j                  d      }t        j                  |d      }|j                  |j                  k(  sJ y N      )gencycle_graphregk_factoredges)selfgfs      Y/var/www/html/venv/lib/python3.12/site-packages/networkx/algorithms/tests/test_regular.pytest_k_factor_trivialz!TestKFactor.test_k_factor_trivial
   s6    OOALLAww!''!!!    c                     t        j                  dd      }t        j                  |d      }|j	                         D ]  }|j                  |d   |d         rJ  |j                         D ]  \  }}|dk(  rJ  y )Nr   r   r      )r	   grid_2d_graphr   r   r   has_edgedegreer   r   g_kfedge_r   s         r   test_k_factor1zTestKFactor.test_k_factor1   sz    a#||Aq!JJL 	0D::d1gtAw///	0 	IAvQ;;	r   c                     t        j                  d      }t        j                  |d      }|j	                         D ]  }|j                  |d   |d         rJ  |j                         D ]  \  }}|dk(  rJ  y )N      r   r   r	   complete_graphr   r   r   r   r   r   s         r   test_k_factor2zTestKFactor.test_k_factor2   sx    q!||Aq!JJL 	0D::d1gtAw///	0 	IAvQ;;	r   c                     t        j                  dd      }t        j                  t        j
                        5  t        j                  |d       d d d        y # 1 sw Y   y xY w)Nr   r    )r	   r   pytestraisesnxNetworkXUnfeasibler   r   r   r   s     r   test_k_factor3zTestKFactor.test_k_factor3   sI    a#]]2001 	LLA	 	 	s   AA#c                     t         j                  j                  dd      }t        j                  t
        j                        5  t        j                  |d       d d d        y # 1 sw Y   y xY wr   )	r	   latticehexagonal_lattice_graphr%   r&   r'   r(   r   r   r)   s     r   test_k_factor4zTestKFactor.test_k_factor4$   sM    KK//15]]2001 	LLA	 	 	s   A$$A-c                     t        j                  d      }t        j                  |d      }|j	                         D ]  }|j                  |d   |d         rJ  |j                         D ]  \  }}|dk(  rJ  y )Nr   r   r   r   r!   r   s         r   test_k_factor5zTestKFactor.test_k_factor5*   sx    q!||Aq!JJL 	0D::d1gtAw///	0 	IAvQ;;	r   N)	__name__
__module____qualname__r   r   r#   r*   r.   r0    r   r   r   r   	   s     "

r   r   c                   $    e Zd Zd Zd Zd Zd Zy)TestIsRegularc                 \    t        j                  d      }t        j                  |      sJ y )Nr   )r	   r
   r   
is_regularr)   s     r   test_is_regular1zTestIsRegular.test_is_regular15   s"    OOA~~a   r   c                 \    t        j                  d      }t        j                  |      sJ y N   )r	   r"   r   r8   r)   s     r   test_is_regular2zTestIsRegular.test_is_regular29   s$    q!~~a   r   c                 ^    t        j                  dd      }t        j                  |      rJ y r;   )r	   lollipop_graphr   r8   r)   s     r   test_is_regular3zTestIsRegular.test_is_regular3=   s)    q!$>>!$$$$r   c                     t        j                         }|j                  g d       t        j                  |      sJ y )N))r   r   )r   r   )r   r   )r'   DiGraphadd_edges_fromr   r8   r)   s     r   test_is_regular4zTestIsRegular.test_is_regular4A   s.    JJL	12~~a   r   N)r1   r2   r3   r9   r=   r@   rD   r4   r   r   r6   r6   4   s    !!%!r   r6   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 nodes)match)r'   Graphr%   r&   NetworkXPointlessConceptr8   )Gs    r   "test_is_regular_empty_graph_raisesrJ   G   sC    

A	r22:N	O 
a  s   AA"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    )r	   r
   r   is_k_regularr)   s     r   test_is_k_regular1z!TestIsKRegular.test_is_k_regular1N   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   )r	   r"   r   rN   r)   s     r   test_is_k_regular2z!TestIsKRegular.test_is_k_regular2S   sW    q!1%%%##Aq)))##Aq))))r   c                     t        j                  dd      }t        j                  |d      rJ t        j                  |d      rJ y )Nr<   r   )r	   r?   r   rN   r)   s     r   test_is_k_regular3z!TestIsKRegular.test_is_k_regular3Y   sC    q!$##Aq)))##Aq))))r   N)r1   r2   r3   rO   rQ   rS   r4   r   r   rL   rL   M   s    *
**r   rL   )r%   networkxr'   networkx.algorithms.regular
algorithmsregularr   networkx.generators
generatorsr	   r   r6   rJ   rL   r4   r   r   <module>rZ      s;       ) ) !( (V! !&* *r   