U
    hh                     @   s   d Z ddlZddlZejdddd Zejdddd Zejd	d
dd Zejd	ddd Z	ejdej
ejejfdd Zejdej
ejejfdd Zdd ZdS )zAUnit tests for the :mod:`networkx.generators.expanders` module.

    Nn)            
   c                 C   s   t | }| | |  kst|D ]Z}||dks8tt|dksHt|D ].}t||ks`td|  krt| k sLn tqLq"d S )N   r   r   )nxmargulis_gabber_galil_graphZnumber_of_nodesAssertionErrorZdegreelenint)r   gnodei r   L/tmp/pip-unpacked-wheel-j2te_plx/networkx/generators/tests/test_expanders.py+test_margulis_gabber_galil_graph_properties
   s    
r   c                 C   s^   t d}t d}dd l}t| }t|jt|	 }|d d|
d k sZtd S )NZnumpyscipyr   r   r   )pytestZimportorskipZscipy.linalgr	   r
   sortedZlinalgZeigvalshZadjacency_matrixZtoarraysqrtr   )r   npspr   r   wr   r   r   (test_margulis_gabber_galil_graph_eigvals   s    


r   p)r   r         c                 C   s   t | }t|| kstdS )z;Test for the :func:`networkx.chordal_cycle_graph` function.N)r	   chordal_cycle_graphr   r   )r   Gr   r   r   test_chordal_cycle_graph#   s    
r"   )r   r   r   r      c                    s   t |  t | kst fdd jD } fdd jD }t|dkrb| | d d ksftt|dkr| | d d kst| d dkr jD ]\}}||f jkstqdS )z3Test for the :func:`networkx.paley_graph` function.c                    s   h | ]}  |qS r   )Z	in_degree.0r   r!   r   r   	<setcomp>7   s     z#test_paley_graph.<locals>.<setcomp>c                    s   h | ]}  |qS r   )Z
out_degreer$   r&   r   r   r'   8   s        r      N)r	   paley_graphr   r   Znodespopedges)r   Z
in_degreesZout_degreesuvr   r&   r   test_paley_graph0   s    
$$r/   
graph_typec              	   C   s.   t jtjdd tjd| d W 5 Q R X d S Nz/`create_using` must be an undirected multigraphmatchr   Zcreate_using)r   raisesr	   NetworkXErrorr
   r0   r   r   r   )test_margulis_gabber_galil_graph_badinputC   s
     r8   c              	   C   s.   t jtjdd tjd| d W 5 Q R X d S r1   )r   r5   r	   r6   r    r7   r   r   r   !test_chordal_cycle_graph_badinputK   s
     r9   c                	   C   s0   t jtjdd tjdtjd W 5 Q R X d S )Nz&`create_using` cannot be a multigraph.r2   r   r4   )r   r5   r	   r6   r*   Z
MultiGraphr   r   r   r   test_paley_graph_badinputS   s
     r:   )__doc__r   Znetworkxr	   markZparametrizer   r   r"   r/   ZGraphZDiGraphZMultiDiGraphr8   r9   r:   r   r   r   r   <module>   s   





