o
    ßË·e   ã                   @   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J ‚dS )z[Tests that the Wiener index of a disconnected graph is
        positive infinity.

        é   ÚinfN)r   r   Úfloat)Úself© r   ú\/var/www/ideatree/venv/lib/python3.10/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J ‚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   ÚGÚHr   r   r   Útest_directed   s   zTestWienerIndex.test_directedc                 C   s,   d}t |ƒ}t|ƒ||d  d ksJ ‚dS )zbTests that the Wiener index of the complete graph is simply
        the number of edges.

        é
   é   r   N)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s$J ‚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   Ú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$   Únetworkxr   r   r   r   r   r   r   r   r   r   Ú<module>   s    