o
    ˷eS                     @   s   d Z ddlZddlZddlmZmZ ddlmZm	Z	m
Z
mZmZmZ G dd dZejde edgfd	d
 ZG dd dZG dd dZdS )z:Generators - Directed Graphs
----------------------------
    N)GraphMultiDiGraph)gn_graph	gnc_graph	gnr_graphrandom_k_out_graphrandom_uniform_k_out_graphscale_free_graphc                   @   s   e Zd Zdd Zdd ZdS )TestGeneratorsDirectedc                 C   sX   t d tdd td td t ddd tdddd tddd tddd d S )Nd         ?*   seed)r   r   r   r	   )self r   ^/var/www/ideatree/venv/lib/python3.10/site-packages/networkx/generators/tests/test_directed.pytest_smoke_test_random_graphs   s   
z4TestGeneratorsDirected.test_smoke_test_random_graphsc                 C   sv  t jtjtdt d t jtjtddt d t jtjtdt d t jtjtdt d tddd}tdt	 dd}t
| t
| ksIJ tdddd}tddt	 dd}t
| t
| ksgJ tddd}tdt	 dd}t
| t
| ksJ tdddddd	tjd
t	ddd}t ttdddd t jttddd t jttddd t jttddd d S )Nr   )create_usingr      r   )r   r   g333333?g?g?   )alphabetagammadelta_in	delta_outinitial_graphr   g333333ӿ)r   )r   )r   )pytestraisesnxNetworkXErrorr   r   r   r   r	   r   sortededgescycle_graph
ValueError)r   GMGr   r   r   #test_create_using_keyword_arguments   s6   
z:TestGeneratorsDirected.test_create_using_keyword_argumentsN)__name__
__module____qualname__r   r'   r   r   r   r   r
      s    r
   ig)r   r   c                 C   s>   t tj td| d W d    d S 1 sw   Y  d S )Nr   )r   )r   r   r   r    r	   )r+   r   r   r   )test_scale_free_graph_initial_graph_kwarg=   s   "r,   c                   @   s    e Zd ZdZdd Zdd ZdS )TestRandomKOutGraphz_Unit tests for the
    :func:`~networkx.generators.directed.random_k_out_graph` function.

    c                    sh   d}d d}t | |}t fdd| D sJ t | |dd}t fdd| D s2J d	S )
2Tests that the generated graph is `k`-out-regular.
      r   c                 3       | ]	\}}| kV  qd S Nr   .0vdkr   r   	<genexpr>O       z6TestRandomKOutGraph.test_regularity.<locals>.<genexpr>r   r   c                 3   r1   r2   r   r3   r7   r   r   r9   Q   r:   N)r   all
out_degree)r   nr   r%   r   r7   r   test_regularityI   s   "z#TestRandomKOutGraph.test_regularityc                 C   s2   d}d}d}t |||dd}t|dksJ dS ) Tests for forbidding self-loops.r/   r0   r   F
self_loopsr   N)r   r   number_of_selfloops)r   r=   r8   r   r%   r   r   r   test_no_self_loopsS   s
   z&TestRandomKOutGraph.test_no_self_loopsN)r(   r)   r*   __doc__r>   rC   r   r   r   r   r-   C   s    
r-   c                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )TestUniformRandomKOutGraphzkUnit tests for the
    :func:`~networkx.generators.directed.random_uniform_k_out_graph`
    function.

    c                    s`   d}d t | }t fdd| D sJ t | dd}t fdd| D s.J dS )	r.   r/   r0   c                 3   r1   r2   r   r3   r7   r   r   r9   h   r:   z=TestUniformRandomKOutGraph.test_regularity.<locals>.<genexpr>r   r   c                 3   r1   r2   r   r3   r7   r   r   r9   j   r:   N)r   r;   r<   r   r=   r%   r   r7   r   r>   c   s   
"z*TestUniformRandomKOutGraph.test_regularityc                    sJ   d}d t | dd}t|dksJ t fdd| D s#J dS )	r?   r/   r0   Fr@   r   c                 3   r1   r2   r   r3   r7   r   r   r9   r   r:   z@TestUniformRandomKOutGraph.test_no_self_loops.<locals>.<genexpr>N)r   r   rB   r;   r<   rF   r   r7   r   rC   l   s
   "z-TestUniformRandomKOutGraph.test_no_self_loopsc                    sD   d}d t | dd}| sJ t fdd| D s J d S )Nr/   r0   Twith_replacementc                 3   r1   r2   r   r3   r7   r   r   r9   y   r:   zCTestUniformRandomKOutGraph.test_with_replacement.<locals>.<genexpr>r   is_multigraphr;   r<   rF   r   r7   r   test_with_replacementt   
   "z0TestUniformRandomKOutGraph.test_with_replacementc                    sD   d}d t | dd}| rJ t fdd| D s J d S )Nr/   r0   FrG   c                 3   r1   r2   r   r3   r7   r   r   r9      r:   zFTestUniformRandomKOutGraph.test_without_replacement.<locals>.<genexpr>rI   rF   r   r7   r   test_without_replacement{   rL   z3TestUniformRandomKOutGraph.test_without_replacementN)r(   r)   r*   rD   r>   rC   rK   rM   r   r   r   r   rE   \   s    	rE   )rD   r   networkxr   networkx.classesr   r   networkx.generators.directedr   r   r   r   r   r	   r
   markparametrizeDiGraphr,   r-   rE   r   r   r   r   <module>   s     
+
