
    wgf                     $    d Z ddlZ G d d      Zy)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
y	)
TestEfficiencyc                     t        j                         | _        | j                  j                  g d       t        j                  d      | _        t        j                  dd      | _        y )N)            r   r   )nxGraphG1add_nodes_fromcycle_graphG2lollipop_graphG3selfs    n/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/networkx/algorithms/tests/test_efficiency.pysetup_methodzTestEfficiency.setup_method   sE    ((*y)..###Aq)    c                 P    t        j                  | j                  dd      dk(  sJ y)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#     }}TWWa+q000r   c                 L    t        j                  | j                        dk(  sJ y)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!     ""477+q000r   c                     t        j                  | j                  dd      dk(  sJ t        j                  | j                  dd      dk(  sJ y )Nr   r   r   g      ?)r
   r   r   r   s    r   test_efficiencyzTestEfficiency.test_efficiency   s@    }}TWWa+q000}}TWWa+u444r   c                 L    t        j                  | j                        dk(  sJ y )Ng?)r
   global_efficiencyr   r   s    r   test_global_efficiencyz%TestEfficiency.test_global_efficiency    s    ##DGG,555r   c                     t        dd      D ]1  }t        j                  |      }t        j                  |      dk(  r1J  y)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#   sB     q" 	0A!!!$A''*a///	0r   c                     t        dd      D ]1  }t        j                  |      }t        j                  |      dk(  r1J  y)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+   sB     q" 	/A!!!$A&&q)Q...	/r   c                 L    t        j                  | j                        dk(  sJ y)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!    
 ""477+v555r   N)__name__
__module____qualname__r   r   r   r   r!   r)   r+   r-    r   r   r   r      s*    *11560/6r   r   )__doc__networkxr
   r   r1   r   r   <module>r4      s    F 46 46r   