o
    3ήci                     @   s<   d Z ddlZddlZddlZddlmZ G dd deZdS )zOriginal NetworkX graph tests    N   )HistoricalTestsc                   @   s`   e Zd Ze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 )TestDiGraphHistoricalc                 C   s   t   tj| _d S N)r   setup_classnxDiGraphG)cls r   U/tmp/pip-target-vg8gfxp4/lib/python/networkx/classes/tests/test_digraph_historical.pyr      s   z!TestDiGraphHistorical.setup_classc              	   C   sj   |   }|d |g d tdd | D g dks!J t| dddddddd	ks3J d S )
NGJK)AB)r   C)r   D)r   r   )r   r   c                 s       | ]\}}|V  qd S r   r   .0ndr   r   r   	<genexpr>       z7TestDiGraphHistorical.test_in_degree.<locals>.<genexpr>r   r   r   r   r      r   r   r   r   r   r   r   r   r	   KJ)r	   add_nodes_fromadd_edges_fromsorted	in_degreedictselfr	   r   r   r   test_in_degree   s   
"
z$TestDiGraphHistorical.test_in_degreec              	   C   sj   |   }|d |g d tdd | D g dks!J t| dddddddd	ks3J d S )
Nr   r   c                 s   r   r   r   )r   kvr   r   r   r   $   r   z8TestDiGraphHistorical.test_out_degree.<locals>.<genexpr>r   r   r   r   r   )r	   r   r    r!   r"   r#   
out_degreer$   r   r   r   test_out_degree    s   
"
z%TestDiGraphHistorical.test_out_degreec                 C   s   t  }|ddg tdd |ddgD ddgksJ tdd |ddgD dd	gks3J td
d |ddgD dd	gksGJ d S )N)r      )r   r   c                 s   r   r   r   r   r   r   r   r   2   r   z<TestDiGraphHistorical.test_degree_digraph.<locals>.<genexpr>r   r+   r   c                 s   r   r   r   r   r   r   r   r   3   r   r   c                 s   r   r   r   r   r   r   r   r   4   r   )r   r   r    r!   r"   r)   degree)r%   Hr   r   r   test_degree_digraph/   s
   ((,z)TestDiGraphHistorical.test_degree_digraphc                 C   s   |   }|d |g d t|ddgksJ t|d dgks'J t|dddgks4J ttj|jd ttj|jd d S )Nr   r   r   r   r   r   j)	r	   r   r    r!   	neighborspytestraisesr   NetworkXErrorr$   r   r   r   test_neighbors6   s   
z$TestDiGraphHistorical.test_neighborsc                 C   s   |   }|d |g d t|dddgksJ t|dddgks*J t|dg ks5J t|dg ks@J t|dg ksKJ ttj|jd ttj|jd d S )	Nr   r   r   r   r   r	   r   r/   )	r	   r   r    r!   
successorsr1   r2   r   r3   r$   r   r   r   test_successorsA   s   
z%TestDiGraphHistorical.test_successorsc                 C   s   |   }|d |g d t|dddgksJ t|dddgks*J t|dg ks5J t|dg ks@J t|dg ksKJ t|dg ksVJ t|dg ksaJ ttj	|jd ttj	|jd d S )	Nr   r   r   r   r   r	   r   r/   )
r	   r   r    r!   predecessorsr5   r1   r2   r   r3   r$   r   r   r   test_predecessorsM   s   
z'TestDiGraphHistorical.test_predecessorsc                 C   sJ   t d}| }| }t ||sJ t| t| ks#J d S )N
   )r   complete_graphto_directedreverseis_isomorphicr!   edges)r%   r	   r-   HRr   r   r   test_reverse\   s
   
 z"TestDiGraphHistorical.test_reversec                    sP   t    fddtddD }  }tddD ]}||d |s%J qd S )Nc                    s   g | ]
}  ||d  qS )r   )add_edge)r   ur-   r   r   
<listcomp>e   s    z7TestDiGraphHistorical.test_reverse2.<locals>.<listcomp>r      r   )r   r   ranger<   has_edge)r%   foor?   rB   r   rC   r   test_reverse2c   s   z#TestDiGraphHistorical.test_reverse2c                 C   s:   t  }|g d | }t| g dksJ d S )N)r   r         )r   r   r   r<   r!   nodes)r%   r-   r?   r   r   r   test_reverse3j   s   z#TestDiGraphHistorical.test_reverse3N)__name__
__module____qualname__classmethodr   r&   r*   r.   r4   r6   r8   r@   rI   rM   r   r   r   r   r   
   s    
r   )__doc__r1   networkxr   historical_testsr   r   r   r   r   r   <module>   s    