o
    3ήc                     @   s&   d dl Zd dlmZ G dd dZdS )    N)pairwisec                   @   s`   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd ZdS )TestVoronoiCellsz*Unit tests for the Voronoi cells function.c                 C   sB   t d}t |h d}dhdhdhddhd}||ksJ d	S )
zhTests that a graph with isolated nodes has all isolates in
        one block of the partition.

           >   r         r   r   r         )r   r   r   unreachableN)nxempty_graphvoronoi_cellsselfGcellsexpected r   M/tmp/pip-target-vg8gfxp4/lib/python/networkx/algorithms/tests/test_voronoi.pytest_isolates   s   
zTestVoronoiCells.test_isolatesc                 C   s<   t d}t |ddh}h dh dd}||ksJ d S )N   r   r   >   r   r   r   >   r   r   r   r   r   )r
   cycle_graphr   r   r   r   r   test_undirected_unweighted   s   
z+TestVoronoiCells.test_undirected_unweightedc                 C   sH   t ttddd}t |ddh}h dh dd}||ks"J d S )	Nr   Tcyclicr   r   >   r   r   r   >   r   r   r   r   )r
   DiGraphr   ranger   r   r   r   r   test_directed_unweighted   s   z)TestVoronoiCells.test_directed_unweightedc                 C   sT   t ttddd}|jdd}t |ddh}h dh d	d
}||ks(J dS )zVTests that reversing the graph gives the "inward" Voronoi
        partition.

        r   Tr   F)copyr   r   >   r   r   r      r   r   r   r   N)r
   r   r   r   reverser   r   r   r   r   test_directed_inward   s
   z%TestVoronoiCells.test_directed_inwardc                 C   J   g d}t  }|| t |ddh}dhh dd}||ks#J d S )N)r   r   
   r   r   r   r   r   r   r   r   r   r   )r
   Graphadd_weighted_edges_fromr   r   edgesr   r   r   r   r   r   test_undirected_weighted+      
z)TestVoronoiCells.test_undirected_weightedc                 C   r"   )N)r#   r%   r&   r   r   r   r   r   r   r   r   r   r   )r
   r   r(   r   r)   r   r   r   test_directed_weighted3   r,   z'TestVoronoiCells.test_directed_weightedc                 C   sP   g d}t d| }t |}t |ddh}t |ddh}||ks&J dS )zcTests that the Voronoi cells for a multigraph are the same as
        for a simple graph.

        ))r   r   )r   r   )r   r   r   r   r   N)r
   
MultiGraphr'   r   r   r*   r   HG_cellsH_cellsr   r   r   test_multigraph_unweighted;   s   
z+TestVoronoiCells.test_multigraph_unweightedc                 C   s\   t ttddd}td| }t|}t|ddh}t|ddh}||ks,J d S )Nr   Tr   r   r   r   )listr   r   r
   MultiDiGraphr   r   r1   r   r   r   test_multidigraph_unweightedG   s   
z-TestVoronoiCells.test_multidigraph_unweightedc                 C   r"   )N)r#   r#   r%   )r   r   d   r&   )r   r   r9   r   r   r   r   )r
   r0   r(   r   r)   r   r   r   test_multigraph_weightedP   r,   z)TestVoronoiCells.test_multigraph_weightedc                 C   r"   )N)r#   r#   r%   r&   )r   r   r$   r-   )r   r   r$   r.   r   r   r   r   )r
   r7   r(   r   r)   r   r   r   test_multidigraph_weightedX   s   

z+TestVoronoiCells.test_multidigraph_weightedN)__name__
__module____qualname____doc__r   r   r   r!   r+   r/   r5   r8   r:   r;   r   r   r   r   r      s    
	r   )networkxr
   networkx.utilsr   r   r   r   r   r   <module>   s    