
    fif                     ,    d Z ddlZ G d d          ZdS )z@Unit tests for the :mod:`networkx.algorithms.efficiency` module.    Nc                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
TestEfficiencyc                     t          j                    | _        | j                            g d           t          j        d          | _        t          j        dd          | _        d S )N)            r   r   )nxGraphG1add_nodes_fromcycle_graphG2lollipop_graphG3selfs    /var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/networkx/algorithms/tests/test_efficiency.pysetup_methodzTestEfficiency.setup_method   sR    (**yyy))).###Aq))    c                 H    t          j        | j        dd          dk    sJ dS )z>
        When nodes are disconnected, efficiency is 0
        r   r   r   N)r
   
efficiencyr   r   s    r   "test_efficiency_disconnected_nodesz1TestEfficiency.test_efficiency_disconnected_nodes   s+     }TWa++q000000r   c                 D    t          j        | j                  dk    sJ dS )z=
        In a disconnected graph the efficiency is 0
        r   N)r
   local_efficiencyr   r   s    r   (test_local_efficiency_disconnected_graphz7TestEfficiency.test_local_efficiency_disconnected_graph   s(     "47++q000000r   c                     t          j        | j        dd          dk    sJ t          j        | j        dd          dk    sJ d S )Nr   r   r   g      ?)r
   r   r   r   s    r   test_efficiencyzTestEfficiency.test_efficiency   sJ    }TWa++q0000}TWa++u444444r   c                 D    t          j        | j                  dk    sJ d S )Ng?)r
   global_efficiencyr   r   s    r   test_global_efficiencyz%TestEfficiency.test_global_efficiency    s&    #DG,,555555r   c                     t          dd          D ]0}t          j        |          }t          j        |          dk    sJ 1dS )zX
        Tests that the average global efficiency of the complete graph is one.
        r   
   r   N)ranger
   complete_graphr    r   nGs      r   %test_global_efficiency_complete_graphz4TestEfficiency.test_global_efficiency_complete_graph#   sT     q" 	0 	0A!!$$A'**a/////	0 	0r   c                     t          dd          D ]0}t          j        |          }t          j        |          dk    sJ 1dS )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&   s      r   $test_local_efficiency_complete_graphz3TestEfficiency.test_local_efficiency_complete_graph+   sT     q" 	/ 	/A!!$$A&q))Q.....	/ 	/r   c                 D    t          j        | j                  dk    sJ dS )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   s    r   test_using_ego_graphz#TestEfficiency.test_using_ego_graph5   s(    
 "47++v555555r   N)__name__
__module____qualname__r   r   r   r   r!   r)   r+   r-    r   r   r   r      s        * * *1 1 11 1 15 5 56 6 60 0 0/ / /6 6 6 6 6r   r   )__doc__networkxr
   r   r1   r   r   <module>r4      sI    F F    46 46 46 46 46 46 46 46 46 46r   