o
    h                     @   s:   d Z ddlZddlZddlZddlmZ G dd dZdS )zEUnit tests for the :mod:`networkx.algorithms.structuralholes` module.    N)dispatch_interfacec                   @   sx   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd ZdS )TestStructuralHolesa  Unit tests for computing measures of structural holes.

    The expected values for these functions were originally computed using the
    proprietary software `UCINET`_ and the free software `IGraph`_ , and then
    computed by hand to make sure that the results are correct.

    .. _UCINET: https://sites.google.com/site/ucinetsoftware/home
    .. _IGraph: http://igraph.org/

    c                 C   sd   t  | _| jg d ddddd| _t  | _| jg d dddddddddd	d
| _d S )
N))r      )r      )r   r   )r   r   r   r   )
)AB)r   F)r   G)r   E)r
   r	   )r   r	   )r   r	   )r   D)r   r	   )r	   C            
   )nxDiGraphr   add_edges_from	D_weightsGraphr	   	G_weights)self r   b/var/www/vscode/kcb/lib/python3.10/site-packages/networkx/algorithms/tests/test_structuralholes.pysetup_method   s$   

z TestStructuralHoles.setup_methodc                 C   s^   t | j}|d tjdddksJ |d tjdddks J |d tjdddks-J d S )Nr   g?5^I?MbP?absr   r   gMbX9?)r   
constraintr   pytestapproxr   r   r   r   r   test_constraint_directed8      z,TestStructuralHoles.test_constraint_directedc                 C   s^   t | j}|d tjdddksJ |d tjdddks J |d tjdddks-J d S )Nr   gy&1?r   r   r   r   )r   effective_sizer   r    r!   r   r%   r   r   r   test_effective_size_directed>   r$   z0TestStructuralHoles.test_effective_size_directedc                 C   z   | j  }t|| jd tj|dd}|d tjdddks!J |d tjdddks.J |d	 tjd
ddks;J d S )Nweightr)   r   gzG?r   r   r   g}?5^I?r   g?5^I?)r   copyr   set_edge_attributesr   r   r    r!   )r   r   r   r   r   r   !test_constraint_weighted_directedD      
z5TestStructuralHoles.test_constraint_weighted_directedc                 C   sz   | j  }t|| jd tj|dd}|d tjdddks!J |d tjdddks.J |d	 tjdddks;J d S )
Nr)   r*   r   gOn?r   r   r   gS?r   )r   r+   r   r,   r   r%   r    r!   )r   r   r%   r   r   r   %test_effective_size_weighted_directedL   r.   z9TestStructuralHoles.test_effective_size_weighted_directedc                 C   ^   t | j}|d tjdddksJ |d tjdddks J |d tjdddks-J d S )	Nr	   g?r   r   r   g
ףp=
?r   r   )r   r   r	   r    r!   r"   r   r   r   test_constraint_undirectedT   r$   z.TestStructuralHoles.test_constraint_undirectedc                 C   r0   )	Nr	   Gz@{Gz?r   r         @r   r   )r   r%   r	   r    r!   r&   r   r   r   'test_effective_size_undirected_borgattiZ   r$   z;TestStructuralHoles.test_effective_size_undirected_borgattic                 C   sx   | j  }t|dd tj|dd}|d tjdddks J |d tjd	ddks-J |d
 tjdddks:J d S )Nr   r)   r*   r	   r2   r3   r   r   r4   r   )r	   r+   r   r,   r%   r    r!   r   r	   r%   r   r   r   test_effective_size_undirected`   s   
z2TestStructuralHoles.test_effective_size_undirectedc                 C   r(   )Nr)   r*   r	   gA`"?r   r   r   gq=
ףp?r   r   )r	   r+   r   r,   r   r   r    r!   r   r	   r   r   r   r   #test_constraint_weighted_undirectedh   r.   z7TestStructuralHoles.test_constraint_weighted_undirectedc                 C   r(   )Nr)   r*   r	   gzG@r3   r   r   g(\@r   r   )r	   r+   r   r,   r   r%   r    r!   r6   r   r   r   'test_effective_size_weighted_undirectedp   r.   z;TestStructuralHoles.test_effective_size_weighted_undirectedc                 C   4   | j  }|d t|}t|d sJ d S Nr   )r	   r+   add_noder   r   mathisnanr8   r   r   r   test_constraint_isolatedx      


z,TestStructuralHoles.test_constraint_isolatedc                 C   sH   | j  }|d t|| jd tj|dd}t|d s"J d S )Nr   r)   r*   )	r	   r+   r=   r   r,   r   r%   r>   r?   r6   r   r   r   test_effective_size_isolated~   s
   

z0TestStructuralHoles.test_effective_size_isolatedc                 C   r;   r<   )r	   r+   r=   r   r%   r>   r?   r6   r   r   r   %test_effective_size_borgatti_isolated   rA   z9TestStructuralHoles.test_effective_size_borgatti_isolatedN)__name__
__module____qualname____doc__r   r#   r'   r-   r/   r1   r5   r7   r9   r:   r@   rB   rC   r   r   r   r   r      s    !r   )rG   r>   r    networkxr   networkx.classes.testsr   r   r   r   r   r   <module>   s    