o
    ]Zh                     @   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            
   )nxZDiGraphr   Zadd_edges_from	D_weightsZGraphr	   	G_weights)self r   ]/var/www/auris/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   r-   )	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	   r/   r0   r   r   r1   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@r0   r   r   g(\@r   r   )r	   r(   r   r)   r   r"   r   r   r3   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isnanr5   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<   r3   r   r   r   test_effective_size_isolated~   s
   

z0TestStructuralHoles.test_effective_size_isolatedc                 C   r8   r9   )r	   r(   r:   r   r"   r;   r<   r3   r   r   r   %test_effective_size_borgatti_isolated   r>   z9TestStructuralHoles.test_effective_size_borgatti_isolatedN)__name__
__module____qualname____doc__r   r    r$   r*   r,   r.   r2   r4   r6   r7   r=   r?   r@   r   r   r   r   r      s    !r   )rD   r;   r   Znetworkxr   Znetworkx.classes.testsr   r   r   r   r   r   <module>   s    