o
    3ήc                     @   s.   d dl Zd dlmZ dd ZG dd dZdS )    N)min_weighted_vertex_coverc                    s   t  fdd|  D S )Nc                 3   s     | ]\}}||h @ V  qd S )N ).0uv
node_coverr   `/tmp/pip-target-vg8gfxp4/lib/python/networkx/algorithms/approximation/tests/test_vertex_cover.py	<genexpr>   s    zis_cover.<locals>.<genexpr>)alledges)Gr   r   r   r	   is_cover   s   r   c                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )TestMWVCzUnit tests for the approximate minimum weighted vertex cover
    function,
    :func:`~networkx.algorithms.approximation.vertex_cover.min_weighted_vertex_cover`.

    c                 C   sf   t  }|dd tddD  |dd tddD  t|}dt|ks*J t||s1J d S )Nc                 s   s    | ]}d |fV  qdS r   Nr   r   r   r   r   r	   r
          z4TestMWVC.test_unweighted_directed.<locals>.<genexpr>      c                 s   s    | ]}|d fV  qdS r   r   r   r   r   r	   r
      r   3   )nxDiGraphadd_edges_fromranger   lenr   )selfr   coverr   r   r	   test_unweighted_directed   s   z!TestMWVC.test_unweighted_directedc                 C   s8   d}t |}t|}dt|ksJ t||sJ d S )N2   r   )r   
star_graphr   r   r   )r   sizesgr   r   r   r	   test_unweighted_undirected   s
   
z#TestMWVC.test_unweighted_undirectedc                    s   t    jddd  jddd  jddd  jddd  jddd  dd  dd  dd  dd  dd  dd  dd  dd t dd}t fd	d
|D }d|ksnJ t |suJ d S )Nr   
   )weightr            r$   c                 3   s    | ]
} j | d  V  qdS )r$   N)nodes)r   nodewgr   r	   r
   5   s    z)TestMWVC.test_weighted.<locals>.<genexpr>)r   Graphadd_nodeadd_edger   sumr   )r   r   csumr   r*   r	   test_weighted"   s$   zTestMWVC.test_weightedc                 C   sh   t  }|d |d |d |dd |dd t|}dt|ks+J t||s2J d S )Nr   r   r%   )r   r,   r-   r.   r   r   r   )r   slgr   r   r   r	   test_unweighted_self_loop9   s   


z"TestMWVC.test_unweighted_self_loopN)__name__
__module____qualname____doc__r   r"   r1   r3   r   r   r   r	   r   	   s    
r   )networkxr   !networkx.algorithms.approximationr   r   r   r   r   r   r	   <module>   s    