U
    ?h                      @   s2   d Z ddlmZmZmZmZmZ G dd dZdS )z<Unit tests for the :mod:`networkx.algorithms.wiener` module.    )DiGraphcomplete_graphempty_graph
path_graphwiener_indexc                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )TestWienerIndexz5Unit tests for computing the Wiener index of a graph.c                 C   s   t tdtdkstdS )z[Tests that the Wiener index of a disconnected graph is
        positive infinity.

           infN)r   r   floatAssertionError)self r   W/var/www/html/venv/lib/python3.8/site-packages/networkx/algorithms/tests/test_wiener.pytest_disconnected_graph
   s    z'TestWienerIndex.test_disconnected_graphc                 C   s,   t d}t|}dt| t|ks(tdS )zvTests that each pair of nodes in the directed graph is
        counted once when computing the Wiener index.

           r   N)r   r   r   r   )r   GHr   r   r   test_directed   s    zTestWienerIndex.test_directedc                 C   s,   d}t |}t|||d  d ks(tdS )zbTests that the Wiener index of the complete graph is simply
        the number of edges.

        
      r   N)r   r   r   )r   nr   r   r   r   test_complete_graph   s    z#TestWienerIndex.test_complete_graphc                    sL   d t  }dt fddtd d d D  }t|}||ksHtdS )zVTests that the Wiener index of the path graph is correctly
        computed.

        	   r   c                 3   s   | ]}| |  V  qd S )Nr   ).0ir   r   r   	<genexpr>@   s     z2TestWienerIndex.test_path_graph.<locals>.<genexpr>r   N)r   sumranger   r   )r   r   expectedactualr   r   r   test_path_graph#   s
    (zTestWienerIndex.test_path_graphN)__name__
__module____qualname____doc__r   r   r   r!   r   r   r   r   r      s
   		r   N)r%   Znetworkxr   r   r   r   r   r   r   r   r   r   <module>   s   