o
    ˷el                     @   s.   d Z ddlZddlZddlZG dd dZdS )zEUnit tests for the :mod:`networkx.algorithms.structuralholes` module.    Nc                   @   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   e/var/www/ideatree/venv/lib/python3.10/site-packages/networkx/algorithms/tests/test_structuralholes.pysetup   s$   

zTestStructuralHoles.setupc                 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_directed6      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_directedB      
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_directedJ   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_undirectedR   r#   z.TestStructuralHoles.test_constraint_undirectedc                 C   r/   )	Nr   Gz@{Gz?r   r         @r   r   )r   r$   r   r   r    r%   r   r   r   'test_effective_size_undirected_borgattiX   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   r1   r2   r   r   r3   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_undirectedf   r-   z7TestStructuralHoles.test_constraint_weighted_undirectedc                 C   r'   )Nr(   r)   r   gzG@r2   r   r   g(\@r   r   )r   r*   r   r+   r   r$   r   r    r5   r   r   r   'test_effective_size_weighted_undirectedn   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isnanr7   r   r   r   test_constraint_isolatedv      


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>   r5   r   r   r   test_effective_size_isolated|   s
   

z0TestStructuralHoles.test_effective_size_isolatedc                 C   r:   r;   )r   r*   r<   r   r$   r=   r>   r5   r   r   r   %test_effective_size_borgatti_isolated   r@   z9TestStructuralHoles.test_effective_size_borgatti_isolatedN)__name__
__module____qualname____doc__r   r"   r&   r,   r.   r0   r4   r6   r8   r9   r?   rA   rB   r   r   r   r   r   	   s    !r   )rF   r=   r   networkxr   r   r   r   r   r   <module>   s
    