
    Vh                         d dl Z d dlZ G d d      Z G d de      Zd Zd Zd Zd	 Zd
 Z	d Z
d Zd Zd Zd Zd Zy)    Nc                   |    e Zd Zej                  Zej                  Zed        Z	d Z
d Zd Zd Zd Zd Zd Zd	 Zy
)TestTreeRecognitionc                 t   | j                         | _        | j                         | _        | j                  j                  d       | j                         | _        | j                  j                  t        d             t        d      D cg c]	  }||dz   f }}| j                  j                  |       | j                         | _	        | j                  j                  t        d             t        d      D cg c]	  }||dz   f }}| j                  j                  |       | j                         | _
        | j                  j                  ddg       | j                  j                  dd       t        j                  | j                  | j                        | _        | j                         | _        | j                  j                  d       | j                  j                  dd       | j                         | _        | j                   j                  t        d             | j                         | _        | j"                  j                  t        d             | j"                  j                  g d       t        j                  | j                  | j"                        | _        y c c}w c c}w )N                  )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iedgess      _/home/dcms/DCMS/lib/python3.12/site-packages/networkx/algorithms/tree/tests/test_recognition.pysetup_classzTestTreeRecognition.setup_class
   s   eAh'%*1X.!QU..e$!eAh'%*1X.!QU..e$q!f%1CFFCFF+1eAh'eAh'67**SVVSVV,3 /
 /s   J0=J5c                     t        j                  t        j                        5  t        j                  | j                                d d d        y # 1 sw Y   y xY wN)pytestraisesr   NetworkXPointlessConceptis_treer   selfs    r&   test_null_treez"TestTreeRecognition.test_null_tree.   s;    ]]2667 	%JJtzz|$	% 	% 	%   $AAc                     t        j                  t        j                        5  t        j                  | j                                d d d        y # 1 sw Y   y xY wr)   )r*   r+   r   r,   r-   r   r.   s    r&   test_null_tree2z#TestTreeRecognition.test_null_tree22   s<    ]]2667 	*JJt()	* 	* 	*r1   c                     t        j                  t        j                        5  t        j                  | j                                d d d        y # 1 sw Y   y xY wr)   )r*   r+   r   r,   	is_forestr   r.   s    r&   test_null_forestz$TestTreeRecognition.test_null_forest6   s;    ]]2667 	'LL&	' 	' 	'r1   c                     t        j                  t        j                        5  t        j                  | j                                d d d        y # 1 sw Y   y xY wr)   )r*   r+   r   r,   r5   r   r.   s    r&   test_null_forest2z%TestTreeRecognition.test_null_forest2:   s<    ]]2667 	,LL*+	, 	, 	,r1   c                     t        j                  | j                        sJ t        j                  | j                        sJ t        j                  | j                        sJ y r)   )r   r-   r   r   r   r.   s    r&   test_is_treez TestTreeRecognition.test_is_tree>   sD    zz$''"""zz$''"""zz$''"""    c                     t        j                  | j                        rJ t        j                  | j                        rJ t        j                  | j                        rJ y r)   )r   r-   r   r    r!   r.   s    r&   test_is_not_treez$TestTreeRecognition.test_is_not_treeC   sG    ::dgg&&&::dgg&&&::dgg&&&&r;   c                 N   t        j                  | j                        sJ t        j                  | j                        sJ t        j                  | j                        sJ t        j                  | j
                        sJ t        j                  | j                        sJ y r)   )r   r5   r   r   r   r   r    r.   s    r&   test_is_forestz"TestTreeRecognition.test_is_forestH   sp    ||DGG$$$||DGG$$$||DGG$$$||DGG$$$||DGG$$$r;   c                     t        j                  | j                        rJ t        j                  | j                        rJ t        j                  | j                        rJ y r)   )r   r5   r   r!   r"   r.   s    r&   test_is_not_forestz&TestTreeRecognition.test_is_not_forestO   sG    <<(((<<(((<<))))r;   N)__name__
__module____qualname__r   Graphr   
MultiGraphr   classmethodr'   r0   r3   r6   r8   r:   r=   r?   rA    r;   r&   r   r      sO    HHEJ!- !-F%*',#
'
%*r;   r   c                   <    e Zd Zej                  Zej                  Zy)TestDirectedTreeRecognitionN)rB   rC   rD   r   DiGraphr   MultiDiGraphr   rH   r;   r&   rJ   rJ   U   s    JJEJr;   rJ   c                      t        j                         } | j                  g d       t        j                  |       rJ t        j                         } | j                  g d       t        j                  |       rJ y )N)r   r   r   )r   r   )r   rE   r   r-   rK   Gs    r&   test_disconnected_graphrP   Z   sZ    

A56zz!}


A56zz!}}r;   c                      t        j                         } | j                  g d       t        j                  |       rJ t        j                  |       sJ y )N)r   r   r   r   )r   rK   r   r-   is_directed_acyclic_graphrN   s    r&   test_dag_nontreerT   e   sA    


A-.zz!}''***r;   c                      t        j                         } | j                  ddg       t        j                  |       rJ t        j                  |       sJ y )Nr   )r   rL   r   r-   rS   rN   s    r&   test_multicyclerV   l   sF    
Aff%&zz!}''***r;   c                      t        j                         } | j                  t        d             t        j                  |       sJ t        j
                  |       rJ y )N
   )r   rK   r   r   is_branchingis_arborescencerN   s    r&   test_emptybranchr[   s   sH    


AU2Y??1!!!$$$$r;   c                      t        j                         } t        j                  t         j                  d      5  t        j
                  |        d d d        y # 1 sw Y   y xY wNzG has no nodes.)match)r   rK   r*   r+   r,   rY   rN   s    r&   $test_is_branching_empty_graph_raisesr_   z   sC    


A	r22:K	L 
     AA"c                      t        j                         } t        j                  | t        d             t        j                  |       sJ t        j
                  |       sJ y )Nr   )r   rK   add_pathr   rY   rZ   rN   s    r&   	test_pathrc      sE    


AKK58??1a   r;   c                      t        j                         } | j                  t        d             | j	                  ddg       t        j
                  |       rJ t        j                  |       rJ y )NrX   r   )r   r   r   rL   r   r   r   rY   rZ   rN   s    r&   test_notbranching1rf      s\    
AU2Yff%&q!!!!!!$$$$r;   c                      t        j                         } | j                  t        d             | j	                  g d       t        j
                  |       rJ t        j                  |       rJ y )NrX   )r   rR   )r   r   re   rN   s    r&   test_notbranching2rh      sX    
AU2Y-.q!!!!!!$$$$r;   c                      t        j                         } | j                  t        d             | j	                  g d       t        j
                  |       sJ t        j                  |       rJ y )NrX   )r   rR   )r   r   )r   r	   re   rN   s    r&   test_notarborescence1rj      sX    
AU2Y56??1!!!$$$$r;   c                      t        j                         } t        j                  | t        d             | j	                  dd       t        j
                  |       rJ t        j                  |       rJ y )Nr   r	   r   )r   rL   rb   r   r   rY   rZ   rN   s    r&   test_notarborescence2rl      sW    
AKK58JJq!q!!!!!!$$$$r;   c                      t        j                         } t        j                  t         j                  d      5  t        j
                  |        d d d        y # 1 sw Y   y xY wr]   )r   rK   r*   r+   r,   rZ   rN   s    r&   'test_is_arborescense_empty_graph_raisesrn      sE    


A	r22:K	L 
1  r`   )r*   networkxr   r   rJ   rP   rT   rV   r[   r_   rc   rf   rh   rj   rl   rn   rH   r;   r&   <module>rp      s\     L* L*^!"5 !
++%!%%%%r;   