
    wg
                     <    d dl Z d dlZ G d d      Z G d d      Zy)    Nc                   @    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)TestMinEdgeCoverz4Tests for :func:`networkx.algorithms.min_edge_cover`c                 p    t        j                         }t        j                  |      t               k(  sJ y N)nxGraphmin_edge_coversetselfGs     l/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/networkx/algorithms/tests/test_covering.pytest_empty_graphz!TestMinEdgeCover.test_empty_graph	   s(    HHJ  #su,,,    c                     t        j                         }|j                  dd       t        j                  |      dhk(  sJ y )Nr   r   r   )r   r   add_edger	   r   s     r   test_graph_with_loopz%TestMinEdgeCover.test_graph_with_loop   s6    HHJ	

1a  #x///r   c                     t        j                         }|j                  d       t        j                  t         j
                  d      5  t        j                  |       d d d        y # 1 sw Y   y xY w)N   zFGraph has a node with no edge incident on it, so no edge cover exists.)match)r   r   add_nodepytestraisesNetworkXExceptionr	   r   s     r   test_graph_with_isolated_vz+TestMinEdgeCover.test_graph_with_isolated_v   sU    HHJ	

1]]  Z
 	! a 		! 	! 	!s   A**A3c                 j    t        j                  dg      }t        j                  |      dhdhfv sJ y )Nr   r   r   r   )r   r   r	   r   s     r   test_graph_single_edgez'TestMinEdgeCover.test_graph_single_edge   s4    HHfX  #6(';;;;r   c                     t        j                  d      }t        j                  |      }t        |      dk(  sJ |j                  D ]  \  }}||f|v r||f|v rJ  y )N      )r   
path_graphr	   lenedges)r   r   	min_coveruvs        r   test_graph_two_edge_pathz)TestMinEdgeCover.test_graph_two_edge_path   sf    MM!%%a(	9~"""GG 	>DAqq6Y&1a&I*===	>r   c                    t        j                         }|j                  g dd       |j                  g dd       |j                  g d       t        j                  |t         j
                  j                  j                  j                        }t        j                  ||      sJ t        |      dk(  sJ t        j                  |      }t        j                  ||      sJ t        |      dk(  sJ y )	N)r   r#   r"      r   )	bipartite)abcr   ))r   r.   )r   r/   )r#   r/   )r#   r0   )r"   r0   )r,   r.      r,   )r   r   add_nodes_fromadd_edges_fromr	   
algorithmsr-   matchingeppstein_matchingis_edge_coverr%   )r   r   r'   
min_cover2s       r   test_bipartite_explicitz(TestMinEdgeCover.test_bipartite_explicit&   s    HHJ	3	A6	UV%%r}}&&//AA
	 9---9~"""&&q)
:...:!###r   c                     t        j                  d      }t        j                  |      }t        j                  ||      sJ t	        |      dk(  sJ y )N
      r   complete_graphr	   r7   r%   r   r   r'   s      r   test_complete_graph_evenz)TestMinEdgeCover.test_complete_graph_even6   J    b!%%a(	9---9~"""r   c                     t        j                  d      }t        j                  |      }t        j                  ||      sJ t	        |      dk(  sJ y )N      r=   r?   s      r   test_complete_graph_oddz(TestMinEdgeCover.test_complete_graph_odd<   rA   r   N)__name__
__module____qualname____doc__r   r   r   r    r*   r9   r@   rE    r   r   r   r      s-    >-0
!<>$ ##r   r   c                   "    e Zd ZdZd Zd Zd Zy)TestIsEdgeCoverz3Tests for :func:`networkx.algorithms.is_edge_cover`c                 l    t        j                         }t        j                  |t                     sJ y r   )r   r   r7   r
   r   s     r   r   z TestIsEdgeCover.test_empty_graphF   s%    HHJ35)))r   c                     t        j                         }|j                  dd       t        j                  |dh      sJ y )Nr   r   r   r   r   r   r7   r   s     r   r   z$TestIsEdgeCover.test_graph_with_loopJ   s3    HHJ	

1aF8,,,r   c                    t        j                         }|j                  dd       t        j                  |ddh      sJ t        j                  |ddh      sJ t        j                  |dh      sJ t        j                  |dh      rJ y )Nr   r   r   rO   r   r   rP   r   s     r   r    z&TestIsEdgeCover.test_graph_single_edgeO   s    HHJ	

1aFF#3444FF#3444F8,,,##Ax0000r   N)rF   rG   rH   rI   r   r   r    rJ   r   r   rL   rL   C   s    =*-
1r   rL   )r   networkxr   r   rL   rJ   r   r   <module>rS      s      :# :#z1 1r   