o
    3ήcM                     @   sz   d dl Z d dlZG dd dZG dd de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 )    Nc                   @   sd   e Zd ZejZej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S )TestTreeRecognitionc                 C   sH  |   | _|   | _| jd |   | _| jtd dd tdD }| j| |  | _	| j	td dd tdD }| j	| |   | _
| j
ddg | j
dd t| j
| j| _|   | _| jd | jdd |   | _| jtd |   | _| jtd	 | jg d
 t| j
| j| _d S )N      c                 S      g | ]}||d  fqS r    .0ir   r   V/tmp/pip-target-vg8gfxp4/lib/python/networkx/algorithms/tree/tests/test_recognition.py
<listcomp>       z3TestTreeRecognition.setup_class.<locals>.<listcomp>   c                 S   r   r   r   r   r   r   r   r      r            )r   r   r      r   r   )graphT1T2add_nodeT3add_nodes_fromrangeadd_edges_from
multigraphT5T6add_edgenxcomposeF1N4N5N6NF1)clsedgesr   r   r   setup_class   s0   







zTestTreeRecognition.setup_classc                 C   @   t tj t|   W d    d S 1 sw   Y  d S N)pytestraisesr"   NetworkXPointlessConceptis_treer   selfr   r   r   test_null_tree0      "z"TestTreeRecognition.test_null_treec                 C   r,   r-   )r.   r/   r"   r0   r1   r   r2   r   r   r   test_null_tree24   r5   z#TestTreeRecognition.test_null_tree2c                 C   r,   r-   )r.   r/   r"   r0   	is_forestr   r2   r   r   r   test_null_forest8   r5   z$TestTreeRecognition.test_null_forestc                 C   r,   r-   )r.   r/   r"   r0   r7   r   r2   r   r   r   test_null_forest2<   r5   z%TestTreeRecognition.test_null_forest2c                 C   s4   t | jsJ t | jsJ t | jsJ d S r-   )r"   r1   r   r   r   r2   r   r   r   test_is_tree@      z TestTreeRecognition.test_is_treec                 C   4   t | jrJ t | jrJ t | jrJ d S r-   )r"   r1   r%   r&   r'   r2   r   r   r   test_is_not_treeE   r;   z$TestTreeRecognition.test_is_not_treec                 C   sT   t | jsJ t | jsJ t | jsJ t | js J t | js(J d S r-   )r"   r7   r   r   r   r$   r&   r2   r   r   r   test_is_forestJ   s
   z"TestTreeRecognition.test_is_forestc                 C   r<   r-   )r"   r7   r%   r'   r(   r2   r   r   r   test_is_not_forestQ   r;   z&TestTreeRecognition.test_is_not_forestN)__name__
__module____qualname__r"   Graphr   
MultiGraphr   classmethodr+   r4   r6   r8   r9   r:   r=   r>   r?   r   r   r   r   r      s    
$r   c                   @   s   e Zd ZejZejZdS )TestDirectedTreeRecognitionN)r@   rA   rB   r"   DiGraphr   MultiDiGraphr   r   r   r   r   rF   W   s    
rF   c                  C   sL   t  } | g d t | rJ t  } | g d t | r$J d S )N)r   r   r   )r   r   )r"   rC   r   r1   rG   Gr   r   r   test_disconnected_graph\   s   rK   c                  C   s6   t  } | g d t | rJ t | sJ d S )N)r   r   r   r   )r"   rG   r   r1   is_directed_acyclic_graphrI   r   r   r   test_dag_nontreeg      rN   c                  C   s6   t  } | ddg t | rJ t | sJ d S )Nr   )r"   rH   r   r1   rM   rI   r   r   r   test_multicyclen   rO   rP   c                  C   s6   t  } | td t | sJ t | rJ d S )N
   )r"   rG   r   r   is_branchingis_arborescencerI   r   r   r   test_emptybranchu   rO   rT   c                  C   s8   t  } t | td t | sJ t | sJ d S )Nr   )r"   rG   add_pathr   rR   rS   rI   r   r   r   	test_path|   s   rV   c                  C   sD   t  } | td | ddg t | rJ t | r J d S )NrQ   r   )r   r   r"   rH   r   r   r   rR   rS   rI   r   r   r   test_notbranching1   
   rX   c                  C   sD   t  } | td | g d t | rJ t | r J d S )NrQ   )r   rL   )r   r   rW   rI   r   r   r   test_notbranching2   rY   rZ   c                  C   sD   t  } | td | g d t | sJ t | r J d S )NrQ   )r   rL   )r   r   )r   r   rW   rI   r   r   r   test_notarborescence1   rY   r[   c                  C   sD   t  } t | td | dd t | rJ t | r J d S )Nr   r   r   )r"   rH   rU   r   r!   rR   rS   rI   r   r   r   test_notarborescence2   s
   r\   )r.   networkxr"   r   rF   rK   rN   rP   rT   rV   rX   rZ   r[   r\   r   r   r   r   <module>   s    Q			