o
    ßË·ef  ã                   @   s   d Z ddlZG dd„ dƒZdS )z@Unit tests for the :mod:`networkx.algorithms.efficiency` module.é    Nc                   @   sL   e 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S )ÚTestEfficiencyc                 C   s8   t  ¡ | _| j g d¢¡ t  d¡| _t  dd¡| _d S )N)é   é   é   é   r   r   )ÚnxÚGraphÚG1Úadd_nodes_fromÚcycle_graphÚG2Úlollipop_graphÚG3©Úself© r   ú`/var/www/ideatree/venv/lib/python3.10/site-packages/networkx/algorithms/tests/test_efficiency.pyÚsetup_method   s   
zTestEfficiency.setup_methodc                 C   s   t  | jdd¡dksJ ‚dS )z>
        When nodes are disconnected, efficiency is 0
        r   r   r   N)r   Ú
efficiencyr	   r   r   r   r   Ú"test_efficiency_disconnected_nodes   s   z1TestEfficiency.test_efficiency_disconnected_nodesc                 C   ó   t  | j¡dks
J ‚dS )z=
        In a disconnected graph the efficiency is 0
        r   N)r   Úlocal_efficiencyr	   r   r   r   r   Ú(test_local_efficiency_disconnected_graph   s   z7TestEfficiency.test_local_efficiency_disconnected_graphc                 C   s4   t  | jdd¡dksJ ‚t  | jdd¡dksJ ‚d S )Nr   r   r   g      à?)r   r   r   r   r   r   r   Útest_efficiency   s   zTestEfficiency.test_efficiencyc                 C   s   t  | j¡dks
J ‚d S )Ng«ªªªªªê?)r   Úglobal_efficiencyr   r   r   r   r   Útest_global_efficiency    s   z%TestEfficiency.test_global_efficiencyc                 C   ó0   t ddƒD ]}t |¡}t |¡dksJ ‚qdS )zX
        Tests that the average global efficiency of the complete graph is one.
        r   é
   r   N)Úranger   Úcomplete_graphr   ©r   ÚnÚGr   r   r   Ú%test_global_efficiency_complete_graph#   s   
þz4TestEfficiency.test_global_efficiency_complete_graphc                 C   r   )z¼
        Test that the local efficiency for a complete graph with at least 3
        nodes should be one. For a graph with only 2 nodes, the induced
        subgraph has no edges.
        r   r   r   N)r   r   r   r   r    r   r   r   Ú$test_local_efficiency_complete_graph+   s   
þz3TestEfficiency.test_local_efficiency_complete_graphc                 C   r   )zˆ
        Test that the ego graph is used when computing local efficiency.
        For more information, see GitHub issue #2710.
        g«ªªªªªâ?N)r   r   r   r   r   r   r   Útest_using_ego_graph5   s   z#TestEfficiency.test_using_ego_graphN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r#   r$   r%   r   r   r   r   r      s    	
r   )Ú__doc__Únetworkxr   r   r   r   r   r   Ú<module>   s    