
    hf                     $    S r SSKr " S S5      rg)z@Unit tests for the :mod:`networkx.algorithms.efficiency` module.    Nc                   D    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
rg)TestEfficiency   c                     [         R                  " 5       U l        U R                  R                  / SQ5        [         R                  " S5      U l        [         R                  " SS5      U l        g )N)            r	   r   )nxGraphG1add_nodes_fromcycle_graphG2lollipop_graphG3selfs    [/var/www/html/env/lib/python3.13/site-packages/networkx/algorithms/tests/test_efficiency.pysetup_methodTestEfficiency.setup_method   sE    ((*y)..###Aq)    c                 T    [         R                  " U R                  SS5      S:X  d   eg)z.
When nodes are disconnected, efficiency is 0
r   r   r   N)r   
efficiencyr   r   s    r   "test_efficiency_disconnected_nodes1TestEfficiency.test_efficiency_disconnected_nodes   s#     }}TWWa+q000r   c                 P    [         R                  " U R                  5      S:X  d   eg)z-
In a disconnected graph the efficiency is 0
r   N)r   local_efficiencyr   r   s    r   (test_local_efficiency_disconnected_graph7TestEfficiency.test_local_efficiency_disconnected_graph   s!     ""477+q000r   c                     [         R                  " U R                  SS5      S:X  d   e[         R                  " U R                  SS5      S:X  d   eg )Nr   r   r   g      ?)r   r   r   r   s    r   test_efficiencyTestEfficiency.test_efficiency   s@    }}TWWa+q000}}TWWa+u444r   c                 P    [         R                  " U R                  5      S:X  d   eg )Ng?)r   global_efficiencyr   r   s    r   test_global_efficiency%TestEfficiency.test_global_efficiency    s    ##DGG,555r   c                     [        SS5       H5  n[        R                  " U5      n[        R                  " U5      S:X  a  M5   e   g)zH
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_graph4TestEfficiency.test_global_efficiency_complete_graph#   s=     q"A!!!$A''*a/// r   c                     [        SS5       H5  n[        R                  " U5      n[        R                  " U5      S:X  a  M5   e   g)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_graph3TestEfficiency.test_local_efficiency_complete_graph+   s=     q"A!!!$A&&q)Q... r   c                 P    [         R                  " U R                  5      S:X  d   eg)zp
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_graph#TestEfficiency.test_using_ego_graph5   s!    
 ""477+v555r   )r   r   r   N)__name__
__module____qualname____firstlineno__r   r   r   r"   r&   r/   r2   r5   __static_attributes__ r   r   r   r      s*    *11560/6r   r   )__doc__networkxr   r   r<   r   r   <module>r?      s    F 46 46r   