o
    3ήc~
                     @   s2   d dl Z d dlZd dlmZmZ G dd dZdS )    N)min_edge_dominating_setmin_weighted_dominating_setc                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestMinWeightDominatingSetc                 C   s   t  }|dd |dd |dd |dd |dd |dd |dd h d}t|}|| D ]}t||}t||@ dksOJ d	q:d S )
N                  >   r   r   r   r	   r   r
   r   zNon dominating set found!)nxGraphadd_edger   set	neighborslen)selfgraphverticesdom_setvertexr    r   b/tmp/pip-target-vg8gfxp4/lib/python/networkx/algorithms/approximation/tests/test_dominating_set.py test_min_weighted_dominating_set   s   z;TestMinWeightDominatingSet.test_min_weighted_dominating_setc                 C   s2   t d}t |ddd}t|dhksJ dS )zTests that an approximate dominating set for the star graph,
        even when the center node does not have the smallest integer
        label, gives just the center node.

        For more information, see #1527.

        
   	   r   )r   r   N)r   
star_graphrelabel_nodesr   r   Gr   r   r   test_star_graph   s   

z*TestMinWeightDominatingSet.test_star_graphc                 C   s   t  }t|t ksJ dS )zGTests that the unique dominating set for the null graph is an empty setN)r   r   r   r   r   r   r   r   test_null_graph*   s   z*TestMinWeightDominatingSet.test_null_graphc                 C   s  t d}t|}| D ]&}||v rq|\}}d}|D ]}|||d kp*||d kO }q|s3J dqt d}t|}| D ]&}||v rHqA|\}}d}|D ]}|||d kp^||d kO }qP|sgJ dqAt  }tjtdd t| W d    d S 1 sw   Y  d S )	Nr   Fr   r   zNon adjacent edge found!r   z"Expected non-empty NetworkX graph!)match)	r   
path_graphr   edgescomplete_graphr   pytestraises
ValueError)r   r   r   edgeuvfounddom_edger   r   r   test_min_edge_dominating_set/   s0   


"z7TestMinWeightDominatingSet.test_min_edge_dominating_setN)__name__
__module____qualname__r   r   r    r-   r   r   r   r   r   
   s
    r   )r%   networkxr   !networkx.algorithms.approximationr   r   r   r   r   r   r   <module>   s    