U
    ?h                     @   s   d Z ddlZG dd dZG dd dZG dd dZG d	d
 d
ZG dd dZG dd dZG dd dZ	G dd dZ
dS )z:Unit tests for the :mod:`networkx.algorithms.cuts` module.    Nc                   @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )TestCutSizez7Unit tests for the :func:`~networkx.cut_size` function.c                 C   sP   t dd}dddh}dddh}t |||dks6tt |||dksLtdS )z%Tests that the cut size is symmetric.   r               Nnxbarbell_graphcut_sizeAssertionErrorselfGST r   U/var/www/html/venv/lib/python3.8/site-packages/networkx/algorithms/tests/test_cuts.pytest_symmetric
   s
    

zTestCutSize.test_symmetricc                 C   sP   t dd}dddh}dddh}t |||dks6tt |||dksLtdS )z!Tests for a cut of a single edge.r   r   r   r   r   r   Nr   r   r   r   r   test_single_edge   s
    

zTestCutSize.test_single_edgec                 C   sT   t dd }dddh}dddh}t |||dks:tt |||dksPtdS )z9Tests that each directed edge is counted once in the cut.r   r   r   r   r   r   Nr	   r
   Zto_directedr   r   r   r   r   r   test_directed   s
    

zTestCutSize.test_directedc                 C   sT   t dd }dddh}dddh}t |||dks:tt |||dksPtdS )	z2Tests that a cut in a directed graph is symmetric.r   r   r   r   r   r      Nr   r   r   r   r   test_directed_symmetric"   s
    

z#TestCutSize.test_directed_symmetricc                 C   s,   t ddg}t |dhdhdks(tdS )z5Tests that parallel edges are each counted for a cut.ababr   N)r	   
MultiGraphr   r   r   r   r   r   r   test_multigraph*   s    zTestCutSize.test_multigraphN)	__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r   r      s   r   c                   @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )
TestVolumez5Unit tests for the :func:`~networkx.volume` function.c                 C   s&   t d}t |ddhdks"td S )Nr   r   r   )r	   cycle_graphvolumer   r   r   r   r   
test_graph3   s    
zTestVolume.test_graphc                 C   s.   t ddddg}t |ddhdks*td S )Nr   r   r   r   r   r   r   r   r   r   r   )r	   DiGraphr&   r   r   r   r   r   test_digraph7   s    zTestVolume.test_digraphc                 C   s<   t td }t|d }t|ddhdks8td S )Nr   r   r   r   r   )listr	   r%   edgesr   r&   r   r   r/   r   r   r   r   r   ;   s    zTestVolume.test_multigraphc                 C   s6   ddddg}t |d }t |ddhdks2td S )	Nr(   r)   r*   r+   r   r   r   r   )r	   ZMultiDiGraphr&   r   r0   r   r   r   test_multidigraph@   s    zTestVolume.test_multidigraphc                 C   sD   t dd}t |dddhdks&tt |dddhdks@td S )Nr   r   r   r      r   r   )r	   r
   r&   r   r   r   r   r   test_barbellE   s    zTestVolume.test_barbellN)	r    r!   r"   r#   r'   r-   r   r1   r3   r   r   r   r   r$   0   s   r$   c                   @   s    e Zd ZdZdd Zdd ZdS )TestNormalizedCutSizezBUnit tests for the :func:`~networkx.normalized_cut_size` function.c                 C   sT   t d}ddh}t|| }t |||}d}||ks<t|t ||ksPtd S )Nr   r   r         ?)r	   
path_graphsetnormalized_cut_sizer   r   r   r   r   sizeexpectedr   r   r   r'   N   s    
z TestNormalizedCutSize.test_graphc                 C   sZ   t dddg}ddh}t|| }t |||}d}||ksBt|t ||ksVtd S )Nr(   r)   r*   r   r   g      @)r	   r,   r7   r8   r   r9   r   r   r   r   Y   s    z#TestNormalizedCutSize.test_directedN)r    r!   r"   r#   r'   r   r   r   r   r   r4   K   s   r4   c                   @   s   e Zd ZdZdd ZdS )TestConductancez:Unit tests for the :func:`~networkx.conductance` function.c                 C   sd   t dd}dh}dh}t |||}d}||ks6tt dd}dddh}t ||dks`td S )	Nr   r   r   皙?r   r   r   g$I$I?)r	   r
   conductancer   )r   r   r   r   r>   r;   ZG2ZS2r   r   r   r'   h   s    
zTestConductance.test_graphNr    r!   r"   r#   r'   r   r   r   r   r<   e   s   r<   c                   @   s   e Zd ZdZdd ZdS )TestEdgeExpansionz=Unit tests for the :func:`~networkx.edge_expansion` function.c                 C   sZ   t dd}ttd}t|| }t |||}d}||ksBt|t ||ksVtd S )Nr   r   r=   )r	   r
   r7   rangeZedge_expansionr   r   r   r   r   	expansionr;   r   r   r   r'   {   s    zTestEdgeExpansion.test_graphNr?   r   r   r   r   r@   x   s   r@   c                   @   s   e Zd ZdZdd ZdS )TestNodeExpansionz=Unit tests for the :func:`~networkx.node_expansion` function.c                 C   s4   t d}dddh}t ||}d}||ks0td S )Nr   r   r   r   g?)r	   r6   Znode_expansionr   r   r   r   rC   r;   r   r   r   r'      s
    

zTestNodeExpansion.test_graphNr?   r   r   r   r   rD      s   rD   c                   @   s   e Zd ZdZdd ZdS )TestBoundaryExpansionzAUnit tests for the :func:`~networkx.boundary_expansion` function.c                 C   s6   t d}ttd}t ||}d}||ks2td S )N
   r   r5   )r	   Zcomplete_graphr7   rA   Zboundary_expansionr   rE   r   r   r   r'      s
    
z TestBoundaryExpansion.test_graphNr?   r   r   r   r   rF      s   rF   c                   @   s   e Zd ZdZdd ZdS )TestMixingExpansionz?Unit tests for the :func:`~networkx.mixing_expansion` function.c                 C   sF   t dd}ttd}t|| }t |||}d}||ksBtd S )Nr   r   gaa?)r	   r
   r7   rA   Zmixing_expansionr   rB   r   r   r   r'      s    zTestMixingExpansion.test_graphNr?   r   r   r   r   rH      s   rH   )r#   Znetworkxr	   r   r$   r4   r<   r@   rD   rF   rH   r   r   r   r   <module>   s   )