
    Vh                        d Z ddlZddlZddlZddlZddlZ ej                  d      Z ej                  d      Z	ej                  d        ej                  d      Zdej                  d<    ej                  d	d
      Zi dddddddddddddddddddd
ddddddddd dd!dd"dd#dddddd$d%d%d&ddd'dd(
d)d*d+dd,d*d-dd.ddd/Zej                   j#                  d0dded   fd1d2f      d3        Zej                   j#                  d4d5      d6        Zd7 Zej                   j*                  d8        Zd9 Zej                   j*                  d:        Zej                   j*                  d;        Zej                   j*                  d<        Zej                   j#                  d=d>      ej                   j#                  d?ej6                  ej8                  f      d@               Zej                   j#                  d?ej6                  ej8                  f      dA        Zej                   j#                  d?ej6                  ej8                  f      dB        ZdC Z ej                   j#                  d?ej6                  ej8                  f      dD        Z!ej                   j#                  d?ej6                  ej8                  f      dE        Z"ej                   j#                  d4ded!   ed!   gfdFdFdFgfdGdFdHgff      ej                   j#                  d?ej6                  ej8                  f      dI               Z#ej                   j#                  d4ded)   ed)   gfdJdJdJgfdKd*dJgff      ej                   j#                  d?ej6                  ej8                  f      dL               Z$dM Z%dN Z&ej                   j*                  dO        Z'dP Z(dQ Z)dR Z*dS Z+ej                   j#                  ddT      dU        Z,ej                   j#                  dVddg      dW        Z-dX Z.dY Z/ej`                  dZ        Z1d[ Z2d\ Z3d] Z4d^ Z5d_ Z6ej                   j#                  d=d`dadbgdcfdddegdffdgdhgdifdjdkgdlff	      ej                   j#                  dmddngf      do               Z7ej                   j#                  d=d`dadbgdcfdddegdffdgdhgdifdjdkgdlff	      ej                   j#                  dmddngf      dp               Z8dq Z9dr Z:ds Z;dt Z<du Z=ej                   j#                  d?ej6                  ej8                  f      dv        Z>ej                   j#                  dwdxdygdyff      dz        Z?ej                   j#                  dwdxdygdyff      d{        Z@ej                   j#                  dmg d|ddnd}gf      d~        ZAd ZBd ZCej                   j#                  dKd      d        ZDej                   j#                  ddgdgdgg ddd*gg df      d        ZEd ZFd ZGej                   j*                  d        ZHd ZId ZJd ZKd ZLd ZMd ZNd ZOd ZPd ZQd ZRej                   j#                  ddg df      d        ZSej                   j#                  ddg df      d        ZTd ZUd ZVej                   j#                  ddT      d        ZWej                   j#                  ddT      d        ZXd ZYd ZZd Z[d Z\ej                   j#                  dej                  ej                  f      d        Z_ej                   j#                  dej                  ej                  f      d        Z`d Zaej                   j#                  d ej8                         dg ej                         d	g ej                         d	gf      d        Zdej                   j#                  d ej8                         dg ej                         d	g ej                         d	gf      d        Zed Zfd Zgd Zhej                   j#                  ddd*iddiddiddHiddHif      d        Ziej                   j#                  dej                  ej                  f      d        Zkej                   j#                  dddg      ej                   j#                  dej                  ej                  ej                  ej                  ej                  g      d               Zpd Zqy)z,Unit tests for matplotlib drawing functions.    N
matplotlibnumpyPSzmatplotlib.pyplotFztext.usetex      node_posnode_visibleT
node_colorz#1f78b4	node_sizei,  
node_label   z#000000z
sans-serifnormal      ?center)
sizecolorfamilyweightalphabackground_colorbackground_alphah_alignv_alignbbox
node_shapeo
node_alphanode_border_widthnode_border_colorfaceedge_visible
edge_width
edge_color
edge_labelround)r   r   r   )boxstyleecfc      ?)
r   r   r   r   r   r   r   r   posrotate
edge_style-
edge_alphaedge_arrowstyleedge_arrowsizearc3)edge_curvatureedge_source_marginedge_target_margin)
param_nameparam_valueexpected)r
   #FF0000red)r
   r   limec                    t        j                  d      }t        j                  |dd       t        j	                         j                  d      }t        j                  |fd|i| |i t        j                  j                  |j                         d   j                         d   |      sJ t        j                          y )Nr   z#00FF00r   o   canvasr   )nx
path_graphset_node_attributespltfigureadd_subplotdisplaymplcolors
same_colorget_childrenget_edgecolorsclose)r5   r6   r7   Gr=   s        Q/home/dcms/DCMS/lib/python3.12/site-packages/networkx/drawing/tests/test_pylab.py$test_display_arg_handling_node_colorrM   C   s     	aA1i1ZZ\%%c*FJJq==J#<=::  !4!4!6q!9!H!H!J1!MxXXXIIK    )r6   r7   ))N)   rO   rO   rO   )r)   )r)   r)   r)   r)   )n_alpha)r   r)   gUUUUUU?      ?c           
         t        j                  d      }t        j                  ||j                         D ci c]  }|d|dz   z   c}d       t        j                         j                  d      }t        j                  |||        t        |j                         d   j                         d d df   |k(        sJ t        j                          y c c}w )Nr   rO   rP   r<   )r=   r   r      )r>   r?   r@   nodesrA   rB   rC   rD   allrH   get_fcrJ   )r6   r7   rK   nr=   s        rL   $test_display_arg_handling_node_alpharX   T   s     	aA1qwwyA!q!q1u+~A9MZZ\%%c*FJJqK8a '')!Q$/8;   IIK Bs   C
c            	         t        j                  d      } t        j                  | | j                         D ci c]  }|||f	 c}d       t        j                         j                  d      }t        j                  | |d       t        j                  |j                         d   j                         j                  ddgddgddgddggk(        sJ t        j                          y c c}w )	Nr   r*   r<   r=   r   r   rO      rS   )r>   r?   r@   rT   rA   rB   rC   rD   nprU   rH   get_offsetsdatarJ   )rK   rW   r=   s      rL   test_display_node_positionr_   g   s    
aA1!'')<Qq1a&y<eDZZ\%%c*FJJq%066a ,,.33AAAQRTUPV7WW   IIK =s   C+
c            
         t        j                         } t        j                         \  }}t        j                  | ddddddd       t        j                  | | j                         D ci c]  }||dk7  rd	nd
|dk7  rdndd c}       t        j                  | ddddd       |j                  d       t        j                          t        j                  d       |S c c}w )a  
    Originally, I wanted to use the exact samge image as test_house_with_colors.
    But I can't seem to find the correct value for the margins to get the figures
    to line up perfectly. To the human eye, these visualizations are basically the
    same.
    r   r   rO   r   r   rO   rO   rO   r)          @r   rO   r[   rS   r   r*   r       tab:blue
tab:orange)r   r   r)   r   Nk)r   r.   r"   r   r   g(\?off)
r>   house_graphrA   subplotsr@   rT   rD   marginstight_layoutaxis)rK   figaxrW   s       rL   test_display_house_with_colorsru   r   s     	AllnGC	v&V:F 	 WWY	

 	  !QD'(Av< 	
	 JJ	 JJtHHUOJ'	
s   +C$
c            
         t        j                         } t        j                  | | j                         D ci c]  \  }}||f||z   dz  rdnd c}}d       t        j                         j                  d      }t        j                  | |d       |j                         D cg c](  }t        |t        j                  j                        r|* c}d   }t        |j                               t        | j                         D cg c]  \  }}||z   dz  sd	 c}}      k(  sJ t        j!                          y c c}}w c c}w c c}}w )
Nr[   -|>r-   
arrowstyler<   
   )r=   r0   r   rO   )r>   karate_club_graphset_edge_attributesedgesrA   rB   rC   rD   rH   
isinstancerE   collectionsLineCollectionlen	get_pathssumrJ   )rK   uvr=   llcs         rL   test_display_line_collectionr      s   
A	aggiHdaQFa!eq[Ec1H, ZZ\%%c*FJJq3 $$&
a778 	

 	
	B
 r||~#QWWY&NTQ1q5A+q&N"OOOOIIK I


 'Os   E '-E
EEc                     t         j                         \  } }t        j                         }t        j                  |d      }t        j
                  ||d       t        g d      }t        j
                  ||j                         D ci c]  }|dd|dk  rdnd	t        |      d
ddd  c}       t        j                  |dd       g d}t        j                  ||j                         D ci c]  \  }}||fddd||f|v d c}}       t        j                  |dd       g d}t        j                  ||j                         D ci c]  \  }}||fd	||f|v d c}}       t        j                  |dd       t         j                          t         j                  d       | S c c}w c c}}w c c}}w )z'See 'Labels and Colors' gallery example   \<1s seedr*   )$a$$b$$c$$d$$\alpha$$\beta$$\gamma$$\delta$i   g?r   ztab:redrj      
whitesmoke)labelr   r   )r   r   r   r   ztab:grey)r   r#   )rc   rO   r[   r[   rS   r   rS      r)   )widthr   r   visibleF)r   r	   )r      r   r   r      )r   r   )r   r   rm   )rA   ro   r>   cubical_graphspring_layoutr@   iterrT   nextrD   r{   r|   rq   rr   )	rs   rt   rK   r*   labelsrW   edgelistr   r   s	            rL   test_display_labels_and_colorsr      s    llnGC
A


1:
.C1c5)		
F 	 WWY	
  &'!e#'<lS	 	
 JJq5Z8 0H	 		
 1 F"q6X-	 	
 JJq5u5/H	 		

 1	 F#q6X- 	
	 JJq5u5HHUOJW	
"	
	
s   	#F2
2F7F=c                     dd l } t        j                         \  }}t        j                         }d}t        | j                  |d            dz  }t        j                         }t        |      D ])  \  }\  }}|j                  ||t        |dz  d             + t        j                  |t        j                  |d	      d
       | j                  | j                  dgdz        D 	cg c]  }	d|	 	 c}	      }
t        j                  ||j                  d      D ci c]  }|t!        |
       c}d       t        j                  ||j                  dd      D ci c]  ^ }}t#        |      |ddid c}}d       t        j$                  |ddt&        j(                  d   d       t        j*                  ||d
       t        j-                          t        j/                  d       |S c c}	w c c}w c c}}w )Nr   ABCr[   )repeatr   rS   )wr   r   r*   g333333?	arc3,rad=Tkeys	curvaturer   )r   r^   r   )r   r   r   r   infernoFrT   rZ   rm   )	itertoolsrA   ro   r>   MultiDiGraphlistproduct	enumerateadd_edger%   r@   r   cycle
accumulater{   r|   r   tupleapply_matplotlib_colorsrE   	colormapsrD   rq   rr   )itrs   rt   rK   rT   prodir   r   rcsier   s                rL   test_display_complexr      s   llnGC
AE

5
+,q0D
At_ ,	6Aq	

1a5Q?
+,1b..qzBEJ
((R]]D6A:-FGisOG
HC1QWW$W5GHq$s)|H+V	 d5	
A !HGQ<88	
 	 q#wi0HPUVJJqe,HHUOJ HH	
s   *G4!G9
"G>c                     t         j                         \  } }t        j                         }|j	                  g d       |j                  ddd       |j                  ddd       |j                  ddd       |j                  ddd	       |j                  dd
d       |j                  ddd       |j                  ddd       |j                  d
dd       |j                  d
dd       |j                  ddd       |j                  ddd       |j                  ddd       |j                  ddd       |j                  ddd       t        j                  |ddd      }t        t        ||dd              }t        j                  |t        j                  |d      d       t        j                  ||j                  d      D ci c]4  \  }}}||f||f|v st        t        ||f            |v rdnd|d   ddd 6 c}}}       t        j                  ||!       t         j!                          t         j#                  d"       | S c c}}}w )#N)ABCDEFrK   Hr   r   r   r   r   r   r      r   r   r   Ir[   r   	      ry   rK   rO   r   r   %   r   r*   T)r^   r9   blackF)r   r+   )r   r   r=   rm   )rA   ro   r>   Graphadd_nodes_fromr   shortest_pathr   zipr@   r   r{   r|   r   reversedrD   rq   rr   )rs   rt   rK   path
path_edgesr   r   ds           rL   test_display_shortest_pathr   	  s.   llnGC

A=>JJsCJ"JJsCJ"JJsCJ"JJsCJ#JJsCJ"JJsCJ"JJsCJ"JJsCJ"JJsCJ#JJsCJ#JJsCJ"JJsCJ"JJsCJ"JJsCJ" AsC9D c$QR)*J1b..qr:EB	 777-
	
 
	
 1a F 1v+uXq!f5E/F*/T  #$X;%@ 
	
 JJqHHUOJ
	
s   9I)r#   r7   )Nr   r   r9   r   r           yellowr   rO   r   rO   r:   )r   blue)#0000FFr   
graph_typec                    t        j                  d|      }t        j                  |dd       t        j	                         j                  d      }t        j                  || |       |j                         rP|j                         D cg c]6  }t        |t        j                  j                        r|j                         8 }}nO|j                  D cg c](  }t        |t        j                  j                        r|* c}d   j!                         }t#        fd|D              sJ t        j%                          y c c}w c c}w )	NrS   create_usingr   r   r<   )r#   r=   r   c              3   ^   K   | ]$  }t         j                  j                  |       & y wN)rE   rF   rG   ).0cr7   s     rL   	<genexpr>z1test_display_edge_single_color.<locals>.<genexpr>T  s"     Baszz$$Q1Bs   *-)r>   r?   r{   rA   rB   rC   rD   is_directedrH   r}   rE   patchesFancyArrowPatchrV   r~   r   
get_colorsrU   rJ   )r#   r7   r   rK   r=   frF   r   s    `      rL   test_display_edge_single_colorr   7  s    	aj1A1i1ZZ\%%c*FJJqZ7}} ((*
!S[[889 HHJ
 
 ''
!S__;;< 
 	 Z\	 	
 B6BBBBIIK

s   ;E-E
c                    t        j                  d|       }t        j                  |dddd       t        j	                         j                  d      }t        j                  ||       d	d
g}|j                         rP|j                         D cg c]6  }t        |t        j                  j                        r|j                         8 }}nP|j                  D cg c])  }t        |t        j                  j                        s(|+ c}d   j!                         }t        j"                  j%                  ||      sJ t        j'                          y c c}w c c}w )NrS   r   r8   r   r   rO   rc   r   r   r<   r   r9   r   r   )r>   r?   r{   rA   rB   rC   rD   r   rH   r}   rE   r   r   rV   r~   r   r   rF   rG   rJ   )r   rK   rt   r7   r   rF   r   s          rL   !test_display_edge_multiple_colorsr   X  s   
aj1A1y)DgN		!	!#	&BJJqvH}} __&
!S[[889 HHJ
 
 ~~
As7U7U)VA

Z\ 	 ::  222IIK

s   ;E)EEc           	      H   t        j                  d|       }t        j                  ||j                         D ci c]  }|||f	 c}d       t        j                         j                  d      }t        j                  ||       |j                         r|j                         D cg c]h  }t        |t        j                  j                        rB|j                         j                  dd d f   |j                         j                  dd d f   fj }}n|j                   D cg c])  }t        |t        j                   j"                        s(|+ c}d   }|j%                         D cg c](  }|j                  dd d f   |j                  dd d f   f* }}d	d
g}	d}
t'        ||	      D ]I  \  }}|\  }}|\  }}t)        t+        ||z
        |
|
fk        rt)        t+        ||z
        |
|
fk        rIJ  t        j-                          y c c}w c c}w c c}w c c}w )NrS   r   r*   r<   r   r   )ra   rd   )rd   r[   r[   g?)r>   r?   r@   rT   rA   rB   rC   rD   r   rH   r}   rE   r   r   get_pathverticesr~   r   r   r   rU   absrJ   )r   rK   rW   rt   r   
end_pointsr   line_collectionpr7   	thresholdar   	act_startact_end	exp_startexp_ends                    rL   test_display_edge_positionr  m  s   
aj1A1!'')<Qq1a&y<eD		!	!#	&BJJq}} __&
!S[[889 ZZ\""1a4(!**,*?*?A*FG

 
 ~~
As7U7U)VA

 <K;T;T;V
67QZZ1qzz"a%01

 
 !"23H IJ) 
1	7	73y9,-I0FFGC'!"i%;;M
 	
 

 IIK5 =


s   H
*A-H()HH.-Hc                      t        j                         } d } ||       }t        j                         j	                  d      }t        j
                  | ||       t        | j                         |j                         d   j                         j                        D ci c]  \  }}|t        |       }}}| j                         D ]  }t        ||   ||   k(        rJ  t        j                          y c c}}w )Nc                 0    t        j                  | d      S )Ni/ r   )r>   r   rK   s    rL   fixed_layoutz4test_display_position_function.<locals>.fixed_layout  s    //rN   r<   )r   r=   r   )r>   rz   rA   rB   rC   rD   r   rT   rH   r]   r^   r   rU   rJ   )rK   r  r*   rt   rW   r  act_poss          rL   test_display_position_functionr    s    
A0 q/C		!	!#	&BJJq<3 !$AGGIr/@/C/O/O/Q/V/V W158G  WWY )3q6WQZ'((()IIKs   !C:c                    t        j                  d|       }t        j                  |dddd       t        j                  d   }t        j
                  |dd|d	
       t        j                         j                  d      }t        j                  ||       t        j                  j                  |      }|j                  dd       |j                  d      |j                  d      g}|j                         rP|j                         D cg c]6  }t!        |t        j"                  j$                        r|j'                         8 }}nO|j(                  D cg c](  }t!        |t        j(                  j*                        r|* c}d   j-                         }t        j.                  j1                  |d   |j2                  d   d         sJ t        j.                  j1                  |d   |j2                  d   d         sJ t        j.                  j1                  ||      sJ t        j5                          y c c}w c c}w )NrS   r   r   rO   r   r   plasmar   Fr   r<   r   cmaprc   r   )r>   r?   r{   rE   r   r   rA   rB   rC   rD   cmScalarMappableset_climto_rgbar   rH   r}   r   r   get_facecolorr~   r   r   rF   rG   r|   rJ   )	r   rK   r  r=   mapperr7   r   rF   r   s	            rL   test_display_edge_colormapsr    s   
aj1A1q!4h?=="Dq(GTGZZ\%%c*FJJq VV"""-F
OOAqq!6>>!#45H}} ((*
!S[[889 OO
 
 ''
!S__;;< 
 	 Z\	 	
 ::  !aggdmG.DEEE::  !aggdmG.DEEE::  6222IIK

s   ;H=-Ic                 N   t        j                  d|       }t        j                  |ddddd       t        j                  d   }t        j
                  |dd	|       t        j                         j                  d
      }t        j                  ||       t        j                  j                  |      }|j                  dd       |j                  d      |j                  d      |j                  d      g}|j                  D cg c])  }t        |t        j                  j                         s(|+ c}d   j#                         }t        j$                  j'                  |d   |j(                  d   d	         sJ t        j$                  j'                  |d   |j(                  d   d	         sJ t        j$                  j'                  |d   |j(                  d   d	         sJ t        j$                  j'                  ||      sJ t        j+                          y c c}w )NrS   r   r   r)   rO   r   rO   r[   r   r  r   r<   r   r  r[   )r>   r?   r@   rE   r   r   rA   rB   rC   rD   r  r  r  r  r~   r}   PathCollectionrI   rF   rG   rT   rJ   )r   rK   r  r=   r  r7   srF   s           rL   test_display_node_colormapsr!    s   
aj1A1!2H==="Dq(GT:ZZ\%%c*FJJq VV"""-F
OOAqq!6>>##6q8IJH%%As7U7U)V			  ::  !aggaj.ABBB::  !aggaj.ABBB::  !aggaj.ABBB::  6222IIKs   
)H"4H"r   r   ry   c           	      n   t        j                  d|      }t        j                  |dddd       t        j	                         j                  d      }t        j                  || |       |j                         rP|j                         D cg c]6  }t        |t        j                  j                        r|j                         8 }}nXt        |j                  D cg c](  }t        |t        j                  j                         r|* c}d	   j#                               }||k(  sJ y c c}w c c}w )
NrS   r   r   ry   r   r   r<   )r"   r=   r   )r>   r?   r{   rA   rB   rC   rD   r   rH   r}   rE   r   r   get_linewidthr   r~   r   get_linewidths)r6   r7   r   rK   r=   r   widthsr   s           rL   test_display_edge_widthr&    s	    	aj1A1q"5w?ZZ\%%c*FJJq[8}} ((*
!S[[889 OO
 
   ++a!?!?@  	  !
 X
s   ;D- -D2:stylec           	         t        j                  d|      }t        j                  |dddd       t        j	                         j                  d      }t        j                  || |       |j                         rP|j                         D cg c]6  }t        |t        j                  j                        r|j                         8 }}n|ddd	}|j                  D cg c](  }t        |t        j                  j                        r|* c}d
   j!                         D 	cg c]  }	||	d
   |	d   t#        |	d         nd f   ! }}	||k(  sJ t        j%                          y c c}w c c}w c c}	w )NrS   r   r-   r'  r   r(  r<   )r,   r=   ))r   N)r   )rO   gffffff?r   rO   )r>   r?   r{   rA   rB   rC   rD   r   rH   r}   rE   r   r   get_linestyler~   r   get_linestylesr   rJ   )
r6   r7   r   rK   r=   r   styles
linestylesr   r   s
             rL   test_display_edge_styler.    sR    	aj1A1sC8'BZZ\%%c*FJJq[8}} ((*
!S[[889 OO
 
 "%c:

  ++a!?!?@  	  !
 !QqT-=eAaDk4HI
 
 XIIK#

s   ;E% -E*#$E/c                     t        j                  d      } t        j                         j	                  d      }t        j
                  | |ddi       |j                         D cg c])  }t        |t        j                  j                        s(|+ }}t        | j                         |      D ]8  \  }}|j                         t        |      k(  sJ |j                         dk(  r8J  t        j!                          y c c}w )Nr   r<   r      )r=   r   g      4@)r>   r?   rA   rB   rC   rD   rH   r}   rE   textTextr   rT   get_textstrget_sizerJ   )rK   r=   tr   rW   r   s         rL   test_display_node_labelsr7    s    
aAZZ\%%c*FJJqVRL9,,.OA*Q2NaOFOAGGIv& $1zz|s1v%%%zz|t###$ IIK	 Ps   %)C?C?c                     t        j                  d      } t        j                         j	                  d      }t        j
                  | | j                         D ci c]  \  }}||fd||z   i c}}       t        j                  | |ddid        |j                         D cg c])  }t        |t        j                  j                        s(|+ }}t        |       t        | j                         |      D ]A  \  }}|j                         t!        |d   |d   z         k(  sJ |j#                         dk(  rAJ  t        j%                          y c c}}w c c}w )	Nr   r<   r   r   r   )r=   r$   r   r   rO   )r>   r?   rA   rB   rC   r{   r|   rD   rH   r}   rE   r1  r2  printr   r3  r4  	get_colorrJ   )rK   r=   r   r   r6  r   r   r   s           rL   test_display_edge_labelsr;    s   
aAZZ\%%c*F 1AGGINDAq1vQ'77NOJJqWcNtL,,.OA*Q2NaOFO	&MAGGIv& $1zz|s1Q4!A$;////{{}###$ IIK OOs   E%)EEc                      t        j                         } t        j                         \  }}t        j                  | |       t        j                          t        j                  d       |S )Nr   rm   )r>   empty_graphrA   ro   rD   rq   rr   )rK   rs   rt   s      rL   test_display_empty_graphr>  -  sG    
AllnGCJJqHHUOJrN   c                  |   t        j                         } | j                  g d       | j                  g d       t        j                  | | j                  d      D ci c]  }|ddt        |d         z    c}d       t        j                         j                  d	      }t        j                  | |
       |j                         D cg c]@  }t        |t        j                  j                        r|j!                         j"                  B }}|g dk(  sJ t        j%                          y c c}w c c}w )N)r   r   r   r   ))r   r   0)r   r   1)r   r   -1)r   r   rA  )r   r   rB  )r   r   r@  Tr   r   皙?r[   r   r<   r   )r   rC  皙ɿrC  rD  r   )r>   
MultiGraphr   add_edges_fromr{   r|   intrA   rB   rC   rD   rH   r}   rE   r   r   get_connectionstyleradrJ   )rK   r   r=   r   radss        rL   (test_display_multigraph_non_integer_keysrK  7  s   
A)*	
	 	agg4g6HIA3QqT?+,,I; ZZ\%%c*FJJq  $$&a445 	
##D 
 3333IIK Js   D4
AD9c                      t        j                         } t        j                  t         j                        5  t        j
                  | d       t        j                          d d d        y # 1 sw Y   y xY w)Nbad_arg)rM  )r>   rz   pytestraisesNetworkXErrorrD   rA   rJ   r  s    rL   test_display_raises_for_bad_argrQ  R  sN    
A	r''	( 


1i(		  s   ,A--A6c            
         t        j                  dt         j                        } t        j                  | | j	                         D ci c]  \  }}||f||z   dz   dz   c}}d       t
        j                         }t        j                  | |       g d|j                         D cg c]6  }t        |t        j                  j                        r|j                         8 c}k(  sJ t
        j                          y c c}}w c c}w )Nr   r   r[   	arrowsizer   )r      1   )r>   r?   DiGraphr{   r|   rA   axesrD   rH   r}   rE   r   r   get_mutation_scalerJ   )rK   r   r   rt   r   s        rL   test_display_arrow_sizerY  Y  s    
abjj1A	;AQFQUQY1$$;[ 
BJJq"a445 	
   
 IIK <s   	D*;Dc            	      x   t        j                  d      } t        j                  | dddddd       t        j                  | | j                         D ci c]  }||dk  
 c}d	       t	        j
                  t         j                        5  t        j                  |        d
d
d
       y
c c}w # 1 sw Y   y
xY w)zP
    This test ensures that a error is raised for incomplete position data.
    r   ra   rd   r   )r   r   )r   rO   r[   r   r*   r   r   N)r>   r?   r@   rT   rN  rO  rP  rD   )rK   rW   s     rL   %test_display_mismatched_edge_positionr[  h  s     	aA1&V6JER1;Aq!a%x;YG 
r''	( 


1  < s   B+
B00B9)r   r   c                 t   t         j                         j                  d      }t        j                  dg      }t        j
                  |dddd       t        j                  |||        |j                         D cg c])  }t        |t        j                  j                        s(|+ c}d   }|j                         j                         ddd	df   }t         j                         j                  d      }t        j                  ||d
d
|        |j                         D cg c])  }t        |t        j                  j                        s(|+ c}d   }|j                         j                         ddd	df   }|d   |d   kD  sJ |d   |d   k  sJ t         j                          yc c}w c c}w )a	  
    Test that there is a wider gap between the node and the start of an
    incident edge when min_source_margin is specified.

    This test checks that the use os min_{source/target}_margin edge
    attributes result is shorter (more padding) between the edges and
    source and target nodes.


    As a crude visual example, let 's' and 't' represent source and target
    nodes, respectively:

       Default:
       s-----------------------------t

       With margins:
       s   -----------------------   t

    r<   rc   ra   rd   r*   )r=   r   r   Nr[   d   )r=   r3   r4   r   rO   )rA   rB   rC   r>   rV  r@   rD   rH   r}   rE   r   r   get_extentscornersrJ   )r   rt   rK   r   default_arrowdefault_extentpadded_arrowpadded_extents           rL   test_display_edge_marginsrd  y  s   * 
	!	!#	&B


F8A1&V4e<JJq
3??$
1ckk6Q6Q(R	M #..088:3Q36BN		!	!#	&BJJ	 ??$
1ckk6Q6Q(R	L !,,.6681a@M nQ////nQ////IIK-s   >)F0(F0')F5F5ticksc           	         t        j                  d      }t        j                  ||j                         D ci c]  }|||f	 c}d       t        j                         }t        j                  ||        |j                  |j                  fD ]   }t        |j                               | k7  r J  t        j                          y c c}w )NrS   r*   )
hide_ticks)r>   r?   r@   rT   rA   rW  rD   xaxisyaxisboolget_ticklabelsrJ   )re  rK   rW   rt   rr   s        rL   test_display_hide_ticksrl    s    
aA1!'')<Qq1a&y<eD	BJJqU#288$ 4D'')*e3334 IIK =s   C
c                     t         j                         } t        j                         }|j	                  d       |j                  dd       t        j                  |ddid       t        j                  ||        | j                         D cg c])  }t        |t        j                  j                        s(|+ c}d   }|j                         }t        |j                         t        |j                          |j                  dkD  r|j                   dkD  sJ t         j#                  |        t         j%                          y c c}w )Nr   ra   r*   r   )rA   rW  r>   rV  add_noder   r@   rD   rH   r}   rE   r   r   r^  r9  r   heightdelaxesrJ   )rt   rK   r   arrowr   s        rL   test_display_self_looprr    s    	B


AJJqMJJq!1q&k51JJq??$
1ckk6Q6Q(R	E D	$**	$++::>dkkAo--KKOIIKs   )E8Ec                      t        j                         } t        j                  |        t        j                  | d      i k(  sJ y)z
    If the pos attribute isn't provided or is a function, display computes the layout
    and adds it to the graph. We need to ensure that this new attribute is removed from
    the returned graph.
    z!display's position attribute nameN)r>   rz   rD   get_node_attributesr  s    rL   test_display_remove_pos_attrru    s9     	AJJqM!!!%HIROOOrN   c               #      K   t         j                         \  } }| |f t         j                  |       t         j                          y wr   )rA   ro   rp  rJ   )rs   rt   s     rL   ro   ro     s2     llnGC
r'MKKOIIKs   AA
c                  (   	 t         j                  t         j                  t         j                  t         j                  t         j
                  t         j                  t         j                  g} ddddg}t        j                  | |      D ]'  \  }} |t        fi | t        j                  d       ) 	 	 t        j                  d       y # t        $ r Y "w xY w# t         $ r Y y w xY w# 	 t        j                  d       w # t         $ r Y w w xY wxY w)Nr   r]  rS   )r
   r   r   test.ps)r>   draw_circulardraw_kamada_kawaidraw_planardraw_randomdraw_spectraldraw_spring
draw_shellr   r   barbellrA   savefigModuleNotFoundErrorosunlinkOSError)	functionsoptionsfunctionoptions       rL   	test_drawr    s      NNNNNNMM
	 #*aHI ) 1 1)W E 	#HfW''KK	"	#	IIi 	  
  			IIi  		s`   B2C 4C* 6C 	CC* CC* 	C'&C'*D,DD	DDDDc                  ~   	 t        t        d            t        t        dd            t        t        dd            g} t        j                  t        |        t
        j                  d       	 t        j                  d       y # t        $ r Y y w xY w# 	 t        j                  d       w # t        $ r Y w w xY wxY w)Nr   ry   r   nlistrx  )
r   ranger>   r  r  rA   r  r  r  r  r  s    rL   test_draw_shell_nlistr    s    eAheArl!3T%B-5HI
gU+I	IIi  			IIi  		sB   A-B 0B 	BBB<B-,B<-	B96B<8B99B<c                  $   	 t        j                  dd      } t        j                  |        t        j	                  d       	 t        j                  d       y # t        $ r Y y w xY w# 	 t        j                  d       w # t        $ r Y w w xY wxY w)Nr[   r   rx  )r>   complete_bipartite_graphdraw_bipartiterA   r  r  r  r  r  s    rL   test_draw_bipartiter    sy    ''1-
!I	IIi  			IIi  		sB   A A( A 	A%$A%(B*B ?B 	B	BBBc                      t        t        j                               } t        j                  t        | dt
        j                  j                  d       y )Nr   T)r#   r   	edge_cmapwith_labels)r  r  number_of_edgesr>   r~  rA   r  Blues)rF   s    rL   test_edge_colormapr    s5    7**,-FNNF!svv||QUrN   c                  R    t        j                  t        j                                y r   )r>   r~  r  to_directed rN   rL   test_arrowsr    s    NN7&&()rN   r   r   r   r9   r   r   r   r   r   r:   )#0000ffr   r  r   r   rc   c                     t        j                  d      }t        j                  |t        j                  |      ||       }t        j
                  j                  |j                         |      sJ y)z`Tests ways of specifying all edges have a single color for edges
    drawn with a LineCollectionrS   r*   r   r#   N)r>   r?   draw_networkx_edgesrandom_layoutrE   rF   rG   r:  )r#   r7   r   rK   drawn_edgess        rL   !test_single_edge_color_undirectedr    s[    & 	aA((	r"X*K ::  !6!6!8(CCCrN   c                    t        j                  dt         j                        }t        j                  |t        j                  |      ||       }|D ]2  }t
        j                  j                  |j                         |      r2J  y)zaTests ways of specifying all edges have a single color for edges drawn
    with FancyArrowPatchesrS   r   r  N)	r>   r?   rV  r  r  rE   rF   rG   get_edgecolor)r#   r7   r   rK   r  faps         rL   test_single_edge_color_directedr  5  sr    & 	abjj1A((	r"X*K  Dzz$$S%6%6%8(CCCDrN   c                     t        j                  dt         j                        } t        t	        |             D ci c]  }|||f	 }}dD ]  }t        j
                  | ||      }|D ]2  }t        j                  j                  |j                         |      r2J  t        j
                  | |ddg|      }|D ]2  }t        j                  j                  |j                         |      r2J   t        j
                  | |g dd	      }|D ]2  }t        j                  j                  |j                         d
      r2J  t        j
                  | |g dd      }|D ]2  }t        j                  j                  |j                         d
      r2J  t        j
                  | |g dd      }t        j                  j                  |d   j                         |d   j                               sJ |D ]2  }t        j                  j                  |j                         d
      s2J  t        j
                  | |g dd	      }t        j                  j                  |d   j                         |d   j                               sJ t        j                  j                  |d   j                         |d   j                               sJ |D ]2  }t        j                  j                  |j                         d
      s2J  yc c}w )zIf edge_color is a sequence with the same length as edgelist, then each
    value in edge_color is mapped onto each edge via colormap.r   r   )r   r   r   rO   rO   r#   rc   r   )r   r#   rc   r   r   r  r   )rc   r   r   )rS   r   r   r   rO   r[   rS   N)
r>   r?   rV  r  r   r  rE   rF   rG   r  )rK   rW   r*   r'   r  r  s         rL   $test_edge_color_tuple_interpretationr  P  s    	abjj1A#CFm
,1q!f9
,C
, ( 
B,,QC 	BC::(():):)<bAAA	B ,,sff-"
  	BC::(():):)<bAAA	B
B ((	31lK  Bzz$$S%6%6%8&AAAB ((	39iK  Bzz$$S%6%6%8&AAAB ((	31iK ::  A$$&A(D(D(F    F::(():):)<fEEEF ((	39lK ::  A$$&A(D(D(F   ::  A$$&A(D(D(F    F::(():):)<fEEEFc -s   Lc                  @   t         j                         } t        j                  t               }d}t        j                  | ||      }t        |t        j                  |            D ]5  \  }}t        j                  j                  |j                         |      r5J  y)zZTest that the edge colors are cycled when there are fewer specified
    colors than edges.r   gbr  N)r  r  r>   r  r  r   r   r   rE   rF   rG   r  rK   r*   
edgecolorsr  r  r7   s         rL   .test_fewer_edge_colors_than_num_edges_directedr    s     	A


7
#C J((CJGK[)//**EF DXzz$$S%6%6%8(CCCDrN   c                  B   t        j                  dt         j                        } t        j                  t              }d}t        j
                  | ||      }t        ||dd       D ]5  \  }}t        j                  j                  |j                         |      r5J  y)z\Test that extra edge colors are ignored when there are more specified
    colors than edges.r   r   )r   r  r  r   r  Nr   )r>   r?   rV  r  r  r  r   rE   rF   rG   r  r  s         rL   -test_more_edge_colors_than_num_edges_directedr    s     	abjj1A


7
#C%J((CJGK[*Sb/: DXzz$$S%6%6%8(CCCDrN   c                  H   t        j                  t        t        j                  t              ddgdd      } | j	                         j                         }t        | j                               dk(  sJ t        j                  j                  |d d d      sJ |d   dk(  sJ y Nrc   r   purplerC  )r*   r   r#   r   r[   r   )r>   r  r  r  r:  squeezer   r   rE   rF   rG   )edge_collectionr'   s     rL   3test_edge_color_string_with_global_alpha_undirectedr    s    ,,W%&!O 
	"	"	$	,	,	.B((*+q000::  CR(333b6S==rN   c                  :   t        j                  t        j                         t        j                  t              ddgdd      } t        |       dk(  sJ | D ]A  }|j                         }t        j                  j                  |d d d      sJ |d   dk(  rAJ  y r  )
r>   r  r  r  r  r   r  rE   rF   rG   )r  r  r'   s      rL   1test_edge_color_string_with_global_alpha_directedr    s    ((W%&!K {q     zz$$RWh777"v}}rN   c                    t        j                  d|       }t        t        |            D ci c]  }|||f	 }}t        j                  ||      }t        |t              r|d   }|j                         dk(  sJ yc c}w )z^Test the default linewidth for edges drawn either via LineCollection or
    FancyArrowPatches.r[   r   r   rO   N)r>   r?   r  r   r  r}   r   r#  )r   rK   rW   r*   r  s        rL   test_edge_width_default_valuer    sx     	aj1A#CFm
,1q!f9
,C
,((C0K+t$!!n$$&!+++	 -s   A=)	edgewidthr7   rS   rS   rS   c                    t        j                  d      }t        t        |            D ci c]  }|||f	 }}t        j                  |||       }t        |j                               dk(  sJ |j                         |k(  sJ y c c}w )Nr   r   rS   )r>   r?   r  r   r  r   r#  )r  r7   rK   rW   r*   r  s         rL   'test_edge_width_single_value_undirectedr    s     	aA#CFm
,1q!f9
,C
,((CyAK{$$&'1,,,$$&(222 -s   Bc                 (   t        j                  dt         j                        }t        t	        |            D ci c]  }|||f	 }}t        j
                  |||       }t	        |      dk(  sJ |D ]  }|j                         |k(  rJ  y c c}w )Nr   r   r  rS   )r>   r?   rV  r  r   r  r#  )r  r7   rK   rW   r*   r  r  s          rL   %test_edge_width_single_value_directedr    s     	abjj1A#CFm
,1q!f9
,C
,((CyAK{q    /  "h.../ -   Br  r   c                    t         j                         }t        j                  |      }d}t        j                  ||| |      }t        |t        j                  |            D ]  \  }}|j                         |k(  rJ  y )N)r)   rf   g      (@)r   r   )	r  r  r>   r  r  r   r   r   r#  )r   rK   r*   r%  r  r  expected_widths          rL   test_edge_width_sequencer    sx     	A


1
CF((C(&QK";	0GH 5^  "n4445rN   c                     t        j                  dt         j                        } t        j                  |       }t        j                  | |ddg      }|D cg c]  }|j                          }}t        j                  | |ddgdd      }|D cg c]  }|j                          }}t        j                  j                  ||      sJ y	c c}w c c}w )
zyTest that edge_vmin and edge_vmax properly set the dynamic range of the
    color map when num edges == len(edge_colors).rS   r   r   r   r  rC  g?)r#   	edge_vmin	edge_vmaxN)	r>   r?   rV  r  r  r  rE   rF   rG   )rK   r*   r  r   orig_colorsscaled_colorss         rL   #test_edge_color_with_edge_vmin_vmaxr    s     	abjj1A


1
C((CQHEK.9:1??$:K:((	3C:K 1<<1Q__&<M<::  m<<< ;
 =s   CCc                  $   t        j                  dt         j                        } t        t	        |             D ci c]  }|||f	 }}t        j
                  | |      }t	        |      dk(  sJ |D ]  }|j                         dk(  rJ  yc c}w )z>Test default linestyle for edges drawn with FancyArrowPatches.r   r   rS   solidNr>   r?   rV  r  r   r  r*  )rK   rW   r*   r  r  s        rL   %test_directed_edges_linestyle_defaultr    s    
abjj1A#CFm
,1q!f9
,C
, ((C0K{q    .  "g---. -s   B)dashed--rO   rd   c                 (   t        j                  dt         j                        }t        t	        |            D ci c]  }|||f	 }}t        j
                  |||       }t	        |      dk(  sJ |D ]  }|j                         | k(  rJ  yc c}w )zTests support for specifying linestyles with a single value to be applied to
    all edges in ``draw_networkx_edges`` for FancyArrowPatch outputs
    (e.g. directed edges).r   r   r(  rS   Nr  )r(  rK   rW   r*   r  r  s         rL   *test_directed_edges_linestyle_single_valuer    s     	abjj1A#CFm
,1q!f9
,C
,((Cu=K{q    ,  "e+++,	 -r  	style_seqr  r  r  )r  r-   r'  )r  r-   r'  z-.c                 h   t        j                  dt         j                        }t        t	        |            D ci c]  }|||f	 }}t        j
                  |||       }t	        |      dk(  sJ t        |t        j                  |             D ]  \  }}|j                         |k(  rJ  yc c}w )zTests support for specifying linestyles with sequences in
    ``draw_networkx_edges`` for FancyArrowPatch outputs (e.g. directed edges).r   r   r  rS   N)
r>   r?   rV  r  r   r  r   r   r   r*  )r  rK   rW   r*   r  r  r(  s          rL   &test_directed_edges_linestyle_sequencer  *  s     	abjj1A#CFm
,1q!f9
,C
,((CyAK{q   +yy'AB ,
U  "e+++,	 -s   B/c                  
   ddl m} m} ddlm} t        j                  t
        j                        }t        j                  t
        j                        }t        j                  |      }t        j                  |      }t        j                  ||      }t        ||      sJ t        j                  ||d      }t        |t              sJ t        |      dkD  rt        |d   |      sJ t        j                  ||d      }t        ||       sJ t        j                  ||d       }t        ||       sJ t        j                  ||d       }t        |t              sJ t        |      dkD  rt        |d   |      sJ y y )Nr   )r   r  )r   r   TarrowsF)matplotlib.collectionsr   r  matplotlib.patchesr   r>   frucht_graphr   rV  r   draw_networkx_nodesr}   r  r   r   )	r   r  r   rK   dGr*   dposrT   r|   s	            rL   test_return_typesr  B  sA   E2
RXX.A	bjj	1B


1
CBD""1c*Ee^,,,""2tD9EeT"""
5zA~%(O444""2tE:Ee^,,,""1d48Ee^,,,""2s48EeT"""
5zA~%(O444 rN   c            
      "   t        j                         } t        j                  |       }t        j                  | |g dddd       t        j                  | |g dddg d       t        j                  | |d	d
       t        j                  | |g ddd
d       t        j                  | |g ddd
d       t        j                  | |g ddd
ddd       i }d|d<   d|d<   d|d<   d|d<   d|d<   d|d<   d|d<   d |d!<   t        d      D ci c]  }||dz  dk(  rd"nd }}t        j                  | ||d#$       t        j                  | ||d#|%       t        j                  | |d d&'       t        j                  | |d(d)i*       y c c}w )+Nr   rO   r[   rS   r   i        ?)nodelistr
   r   r   )r   r   r   r   r  )rQ   r)   r  r   r   r)   )r   r   )rc   r   r   )rS   r   r   )r   r   r   r#   )r   r   r   )r   r   T)r   r  min_source_marginmin_target_marginr   r#   r   r   r   rO   r   r[   r   rS   r   r   r   r   r   r   r   r   rl      )	font_size)r  
font_colorF)edge_labelsr+   r   z4-5r  )r>   r   r   r  r  r  draw_networkx_labelsdraw_networkx_edge_labels)rK   r*   r   rW   rF   s        rL   test_labels_and_colorsr  \  s   
A


1
C	3#D 	$ 1cC8	1 	1 	1	 FF1IF1IF1IF1IF1IF1IF1IF1I5:1X>aA
+>F>AsFb9AsFbVL  CT%H  Cfe_E	 ?s   Fc                     t        j                         } t        j                         \  }}dddddd}t        j                  | |dg dd	
       t        j                  | |ddgd
       t        j
                  | |dd       |j                  d       t        j                          t        j                  d       |S )Nra   rb   rc   rd   re   rg   rh   r  rj   )r   r  r
   ri   r   rk   r)   r   )r   r   g)\(?rm   )	r>   rn   rA   ro   r  r  rp   rq   rr   )rK   rs   rt   r*   s       rL   test_house_with_colorsr    s    
AllnGCFv*
EC 	 	3$! 1cA6JJtHHUOJrN   c                     | \  }}t        j                  t        |       t        j                  t        t        j                  t              |       y )Nrt   )r>   drawr  r  circular_layout)ro   rs   rt   s      rL   	test_axesr    s6    GCGGG  "*<*<W*E"MrN   c                  V    t        j                         } t        j                  |        y r   )r>   r   r  r  s    rL   test_empty_graphr    s    

AGGAJrN   c                  r   dd l } t        j                  ddg      }t        j                  ddg      }t        j                  |      }t        t        j                  ||g       t        j                  j                        sJ t        t        j                  ||g       t        j                  j                        sJ t        j                  ||g d      g k(  sJ t        j                  ||g d      g k(  sJ t        j                  ||g d      g k(  sJ t        j                  ||g d      g k(  sJ y )Nr   r   r   )r  T)r   r  F)r  r>   r   rV  r  r}   r  rE   r~   r  r  )r   rK   DGr*   s       rL   #test_draw_empty_nodes_return_valuesr    s   !
&&!"A	VV$	%B


Q
C
q#3S__5S5S   
r34coo6T6T   !!!S2dCrIII!!!S2eDJJJ!!"cBuEKKK!!"cBtDJJJrN   c                      t        j                  dt         j                        } t        j                  | dg       t        j                  | dgg d       y )NrS   r   )r   rO   r   r   )ry   r0  r   )r   r   )r>   r?   r   draw_networkxr  s    rL   test_multigraph_edgelist_tuplesr    s<    
aboo6AQ)-Q)DrN   c                     t        j                  t              } t        j	                         }|j                  d       t        j                  t        | ddg       t        t        j                        }t        |      D cg c]  }||z  	 }}t        |      }|j                  d       t        j                  t        | ||       |j                  d       |j                  d       t        j                  t        | |       y c c}w )	N   皙?rC  )r      )r
   r   rO      )r>   r  r  rA   rB   rC   r  r   rT   r  append)r*   rs   	num_nodesxr   rF   s         rL   test_alpha_iterr    s    


7
#C
**,COOC7CSz:GMM"I$))$45qQ]5E59FOOC7CF%H	LLOOOC7Cu5 6s   D	c                    | \  }}t        j                  d      }t        j                  |g d|       |j                         D cg c])  }t	        |t
        j                  j                        s(|+ }}t        |      dk(  sJ y c c}w )Nr   )r   hr   ^)r   rt   )	r>   r?   r  rH   r}   rE   r~   r  r   )ro   rs   rt   rK   r   scatterss         rL   test_multiple_node_shapesr    sw    GC
aAGGA.26??$
1coo6T6T(UH  x=As   )B1Bc                    t        j                         }| \  }}t        j                  |||j                         D ci c]  }||dz  rdnd c}|j                         D ci c]  }|t	        |dz  dz          c}       t        |j                         |j                         D cg c]D  }t        |t        j                  j                        rt        |j                               dkD  r|F c}      D ]b  \  }}|dz  rdnd	}t        j                  j                  |j                         |      sJ t	        |dz  dz         |j!                         k(  rbJ  y c c}w c c}w c c}w )
Nr[   rl   r   g""""""@r   )rt   r  r  r   r   r9   )r>   rz   r  rT   rG  r   rH   r}   rE   r1  r2  r   r3  rF   rG   r:  r5  )ro   rK   rs   rt   rW   r6  r7   s          rL   #test_individualized_font_attributesr    s8   
AGCGG	67ggi@Aa!es,@67ggi@1c!w-!+,,@	 		 __&	
!SXX]]+AJJL0AA0E 	
 61  !e7zz$$Q[[]H===1=1$%5556 A@	
s   E"E$)A	E)
c                 L   t        j                         }| \  }}|j                         D cg c]  \  }}||z   dz  dk(  rdnd }}}|j                         D cg c]  \  }}d|dz  |dz  z   z  dz    }}}t        j                  ||d||       |j	                         D cg c])  }t        |t        j                  j                        s(|+ }	}t        |j                         |	      D ]  \  }
}|j                         d|
d   dz  |
d   dz  z   z  dz   k(  sJ t        |
      dz  r$t        j                  j                  j                  n#t        j                  j                  j                  }t        |j                         |      rJ  y c c}}w c c}}w c c}w )	Nr[   r   rw   -[ry   T)rt   r  rx   rS  rO   )r>   rz   r|   r  rH   r}   rE   r   r   r   rX  r   
ArrowStyleBracketBCurveFilledBget_arrowstyle)ro   rK   rs   rt   r   r   arrowstyles
arrowsizesr   r  r   r  r7   s                rL   #test_individualized_edge_attributesr    s   
AGCCD779M41aQUaK1,5$6MKM89	B1"AA&+BJBGGA"TkZP??$
1ckk6Q6Q(RF  AGGIv& 81##%qtax!A$(/B)Cb)HHHH 1vz KK""++''44 	
 !**,h7778 NBs   FF&)F!F!c                      t        j                  t        d      5  t        j                  t
        d       d d d        y # 1 sw Y   y xY w)NzReceived invalid argumentmatchbar)foo)rN  rO  
ValueErrorr>   r  r  r  rN   rL   test_error_invalid_kwdsr&  !  s4    	z)D	E $
U#$ $ $s   AA
c                      t        j                  g d      } g d}t        j                  t        d      5  t        j
                  | |       d d d        y # 1 sw Y   y xY w)N)rc   r   r[   r   rO   rS   )rO   r[   rS   z1arrowsize should have the same length as edgelistr!  )rS  )r>   rV  rN  rO  r%  r  )rK   rS  s     rL   +test_draw_networkx_arrowsize_incorrect_sizer*  &  sM    


34AI	M
 ( 	Y'( ( (s   AA!rS     )ry   r0  r+  c                 Z   t        j                  g d      }dddd}t        j                  |||       }t        | t              rt        j                  |       n| } t        ||       D ]@  \  }}t        |t        j                  j                        sJ |j                         |k(  r@J  y )Nrc   r(  r   ra   rc   rb   r  )r*   rS  )r>   rV  r  r}   rG  r   r   r   rE   r   r   rX  )rS  rK   r*   r|   r  r7   s         rL   test_draw_edges_arrowsizer.  /  s    


+,AF
+C""1#CE/9)S/I	  +yIUI. 4X#s{{::;;;%%'83334rN   rx   rw   rw   r  z<|-|>c                 F   t        j                  g d      }dddd}t        j                  |||       }t        | t              rt        j                  |       n| } t        j                  j                  j                  t        j                  j                  j                  t        j                  j                  j                  d}t        ||       D ]J  \  }}t        |t        j                  j                        sJ t        |j                         ||         rJJ  y )Nr-  ra   rc   rb   r  )r*   rx   r/  )r>   rV  r  r}   r4  r   r   rE   r   r  r  r  CurveFilledABr   r   r  )rx   rK   r*   r|   arrow_objectsr  r7   s          rL   test_draw_edges_arrowstyler3  <  s    


+,AF
+C""1#*EE )3:s(C	$ 
 {{%%22kk$$--''55M UJ/ IX#s{{::;;;#,,.h0GHHHIrN   c                  d    t        j                  t        t        j	                  ddg             y )Nr(  r   r  )r>   r  r  r\   arrayr  rN   rL   test_np_edgelistr6  Q  s     Wrxx0@'ABrN   c                      t        j                  d      } ddd}t        j                  t         j                  d      5  t        j
                  | |       d d d        y # 1 sw Y   y xY w)NrS   ra   rd   rc   zhas no positionr!  )r>   r?   rN  rO  rP  r  )rK   r*   s     rL   *test_draw_nodes_missing_node_from_positionr8  V  sT    
aA
 C	r''/@	A '
q#&' ' 's    A  A)c                    |\  }}t        j                  dg      }ddd}t        j                  ||||       d   }|j                         j	                         ddddf   }t        j                  |||| dd	      d   }|j                         j	                         ddddf   }	|	d   |d   kD  sJ |	d
   |d
   k  sJ y)  Test that there is a wider gap between the node and the start of an
    incident edge when min_source_margin is specified.

    This test checks that the use of min_{source/target}_margin kwargs result
    in shorter (more padding) between the edges and source and target nodes.
    As a crude visual example, let 's' and 't' represent source and target
    nodes, respectively:

       Default:
       s-----------------------------t

       With margins:
       s   -----------------------   t

    rc   ra   rb   rt   r   r   Nr[   r]  rt   r   r  r  rO   )r>   rV  r  r^  r_  )
r   ro   rs   rt   rK   r*   default_patchra  padded_patchrc  s
             rL   )test_draw_edges_min_source_target_marginsr?  _  s    & GC


F8A
 C **1cbZPQRSM"..088:3Q36BN ))	 	L !,,.6681a@M nQ////nQ////rN   c           	         |\  }}t        j                  ddg      }dddd}t        j                  ||||       }|D cg c](  }|j                         j	                         ddd	d
f   * }}t        j                  |||| ddgddg      }	|	D 
cg c](  }
|
j                         j	                         ddd	d
f   * }}
t        ||      D ]  \  }}
|
d
   |d
   kD  sJ |
d   |d   k  rJ  yc c}w c c}
w )r:  rc   r   ra   rb   )r[   r   r  r;  Nr[   r   b   f   r<  rO   )r>   rV  r  r^  r_  r   )r   ro   rs   rt   rK   r*   r=  r   ra  r>  r  rc  s               rL   4test_draw_edges_min_source_target_margins_individualrC    s"   & GC


FF#$AF
+C **1cbZPMANOAammo--/!Q7ONO ))	s)s)L AMM1Q]]_,,.ssAv6MMMNM2 1 tad{{tad{{ P Ns    -C0-C5c                    | \  }}t        j                         }|j                  d       |j                  dd       t        j                  |ddi      d   }|j                         }|j                  dkD  r|j                  dkD  sJ y)zDEnsure that selfloop extent is non-zero when there is only one node.r   ra   N)r>   rV  rn  r   r  r^  r   ro  )ro   rs   rt   rK   patchr   s         rL   &test_nonzero_selfloop_with_single_noderF    sw     GC


AJJqMJJq!""1q&k215ED::>dkkAo--orN   c                 V   | \  }}t        j                  dt         j                        }|j                  dd       |j                  D ci c]  }|||f	 }}t        j
                  ||dg      d   }|j                         }|j                  dkD  r|j                  dkD  sJ yc c}w )zfEnsure that selfloop extent is non-zero when only a single edge is
    specified in the edgelist.
    r[   r   rO   rd   r  r   N)	r>   r?   rV  r   rT   r  r^  r   ro  )ro   rs   rt   rK   rW   r*   rE  r   s           rL   2test_nonzero_selfloop_with_single_edge_in_edgelistrH    s    
 GC
abjj1AJJq!gg
&1q!f9
&C
&""1cVH=a@ED::>dkkAo--o 's   B&c                      g d} g d}d}t         j                  j                  j                  |||       }t	        |dddf   |k(        sJ y)zfTest apply_alpha when there is a mismatch between the number of
    supplied colors and elements.
    r  r  r)   Nr   )r>   drawingnx_pylabapply_alpharU   )r  	colorlistr   rgba_colorss       rL   test_apply_alpharO    sM     HIE**%%11)UHMK{1b5!U*+++rN   c                  Z   ddl } ddl} t        j                  d      }t        j                  dt        j                        }|D ci c]  }|||f	 }}||fD ]f  }t        j
                  ||d      }t        |      t        |j                        k(  sJ t        |d   t        j                  j                        rfJ  ||fD ]@  }t        j
                  ||d      }t        |t        j                  j                        r@J  t        j
                  ||      }t        |t        j                  j                        sJ t        j
                  ||      }t        |      t        j                        k(  sJ t        |d   t        j                  j                        sJ yc c}w )a/  
    The `arrows` keyword argument is used as a 3-way switch to select which
    type of object to use for drawing edges:
      - ``arrows=None`` -> default (FancyArrowPatches for directed, else LineCollection)
      - ``arrows=True`` -> FancyArrowPatches
      - ``arrows=False`` -> LineCollection
    r   NrS   r   Tr  F)r  r  r>   r?   rV  r  r   r|   r}   rE   r   r   r~   r   )r   UGr  rW   r*   rK   r|   s          rL   *test_draw_edges_toggling_with_arrows_kwargrR    sl    "	q	B	qrzz	2B 
!1q!f9
!C
! "X A&&q#d;5zS\)))%(CKK$?$?@@@A "X A&&q#e<%!?!?@@@A
 ""2s+EeS__;;<<<""2s+Eu:QWW%%%eAh ; ;<<<% "s   F(drawing_funcc                     dd l }t        j                  d      }|\  }} | ||       t        d |j                  D              sJ |j
                  rJ y )Nr   rS   r  c              3   d   K   | ](  }t        |t        j                  j                         * y wr   r}   rE   r~   r   r   r   s     rL   r   z?test_draw_networkx_arrows_default_undirected.<locals>.<genexpr>  s!     Uz!S__;;<U   .0)r  r>   r?   anyr~   r   rS  ro   r   rK   rs   rt   s         rL   ,test_draw_networkx_arrows_default_undirectedr[    sL    !
aAGCrUbnnUUUUzz>zrN   c                     dd l }t        j                  dt        j                        }|\  }} | ||       t	        d |j
                  D              rJ |j                  sJ y )Nr   rS   r   r  c              3   d   K   | ](  }t        |t        j                  j                         * y wr   rV  rW  s     rL   r   z=test_draw_networkx_arrows_default_directed.<locals>.<genexpr>  s&      :;
1coo445rX  )r  r>   r?   rV  rY  r~   r   rZ  s         rL   *test_draw_networkx_arrows_default_directedr^    s]    !
abjj1AGCr ?A~~    :::rN   c                     t        j                  d      }|j                  dd       | \  }}t        j                  |ddg|       |j                  rJ y )NrS   r   rc   r   )r   rt   )r>   r?   r   r  r   )ro   rK   rs   rt   s       rL   test_edgelist_kwarg_not_ignoredr`     sJ    
aAJJq!GCGGA(R0zz>zrN   )rK   expected_n_edgesr[   c           	      @   t        g d      D ])  \  }\  }}| j                  ||t        |dz  d             + | D ci c]  }|||f	 }}dddgg dfD ]B  }t        j                  | ||       t        j                  | ||      }t        |      |k(  rBJ  yc c}w )	zGDraws edges correctly for 3 types of graphs and checks for valid lengthrc   rc   rc   r(  rS   r[   r   arc3,rad=0.1)rd  rd  arc3,rad=0.2connectionstyleN)r   r   r%   r>   r  r   )	rK   ra  r   r   r   rW   r*   
conn_styler  s	            rL   2test_draw_networkx_edges_multiedge_connectionstyleri  )  s     ?@ 1	6Aq	

1aa!eQ
01
 1q!f9
 C
  		(8 /

 	q#zB''3
K6{..../ !s   Bc           	         t        g d      D ])  \  }\  }}| j                  ||t        |dz  d             + | D ci c]  }|||f	 }}t        j                  | |g d      }dddgg dfD ]Z  }t        j
                  | ||      }	t        |	      |k(  sJ |	j                         D ]  }
|
j                  j                  d	k(  rJ  \ y
c c}w )zXDraws labels correctly for 3 types of graphs and checks for valid length and class namesrc  rS   r[   r   )rd  rd  rd  rf  rd  re  CurvedArrowTextN)
r   r   r%   r>   r  r  r   values	__class____name__)rK   ra  r   r   r   rW   r*   r  rh  
text_itemstis              rL   8test_draw_networkx_edge_labels_multiedge_connectionstylerq  =  s     ?@ 1	6Aq	

1aa!eQ
01
 1q!f9
 C
 ##	3 PF 		(8 >

 11!S*U
:"2222##% 	>B<<((,====	>> !s   Cc                  ,   t        j                         } | j                  ddd       | j                  ddd       t        j                  | d      }| D ci c]  }|||f	 }}t        j                  | ||ddg	      }t        |      d
k(  sJ y c c}w )Nr   rO   ry   r   r0  r   rd  re  r  rg  r[   )r>   rE  r   get_edge_attributesr  r   )rK   r  rW   r*   ro  s        rL   'test_draw_networkx_edge_label_multiedgeru  U  s    
AJJq!BJJJq!BJ((H5K
 1q!f9
 C
 --	'8	J z?a !s   Bc                      t        j                  d      } | j                  D ci c]  }|||f	 }}t        j                  | |i       i k(  sJ yc c}w )zORegression test for draw_networkx_edge_labels with empty dict. See
    gh-5372.rS   r  N)r>   r?   rT   r  )rK   rW   r*   s      rL   (test_draw_networkx_edge_label_empty_dictrw  d  sS     	aAgg
&1q!f9
&C
&''3B?2EEE 's   Ac                 :   | \  }}g d}g d}t        j                  |      }|j                  D ci c]  }|||f	 }}t        j                  |||||       t	        |j
                        dk(  sJ t        j                  |dd       t        j                  ddg      z   }t        |j
                  |dd |      D ]W  \  }	}
}|	j                         j                  |      sJ t        j                  j                  |	j                         |
      rWJ  yc c}w )	ztWhen an edgelist is supplied along with a sequence of colors, check that
    the self-loops have the correct colors.)r)  r   r   rd   r  r   )pinkcyanr   r9   r   green)rt   r   r#   rS   Nr   r	  )r>   r   rT   r  r   r   r\   r5  r   r   contains_pointrE   rF   rG   r  )ro   rs   rt   r   edge_colorsrK   rW   r*   	sl_pointsr  clrslps               rL   3test_draw_networkx_edges_undirected_selfloop_colorsr  l  s    GC?HCK
Agg
&1q!f9
&C
&1cb8T rzz?a
 "#'"((As8*<<I RZZRS)99E ?S#||~,,S111zz$$S%6%6%8#>>>? 's   Dfap_only_kwargr0  rg  re  r  r  c                    t        j                  d      }|D ci c]  }|||f	 }}|\  }}t        | j                               d   }t	        j
                  t        d| d      5  t        j                  ||fd|i|  ddd       t        j                         5  t        j                  d       t        j                  d	t        
       t        j                  ||f|dd|  ddd       yc c}w # 1 sw Y   vxY w# 1 sw Y   yxY w)zUsers should get a warning when they specify a non-default value for
    one of the kwargs that applies only to edges drawn with FancyArrowPatches,
    but FancyArrowPatches aren't being used under the hood.rS   r   z

The z# keyword argument is not applicabler!  rt   Nerrorignore)categoryT)rt   r  )r>   r?   r   r   rN  warnsUserWarningr  warningscatch_warningssimplefilterfilterwarningsDeprecationWarning)r  ro   rK   rW   r*   rs   rt   
kwarg_names           rL   1test_user_warnings_for_unused_edge_drawing_kwargsr    s    	aA
 1q!f9
 C
 GC n))+,Q/J	Xj\1TU
 @ 	q#?"??@ 
	 	 	" Mg&3EF
q#L"TL^L	M M !
@ @M Ms   C2(C7AD7D Ddraw_fnc                     |\  }}t        j                  d      }t        j                  d      5 } | ||       d d d        t	              dk(  sJ y # 1 sw Y   xY w)Nr   T)recordr  r   )r>   cycle_graphr  r  r   )r  ro   rs   rt   rK   r   s         rL   *test_no_warning_on_default_draw_arrowstyler    sZ     GC
qA		 	 	- bq6Q;; s   AArg  methodc                    t        j                  d      }|j                  D ci c]  }|||f	 }}|\  }} | ||||       |j                  |j                  fD ]   }t        |j                               |k7  r J  y c c}w )NrS   )r*   rt   rg  )r>   r?   rT   rh  ri  rj  rk  )	r  rg  ro   rK   rW   r*   _rt   rr   s	            rL   test_hide_ticksr    s     	aAgg
&1q!f9
&C
&EAr
1#"4288$ 9D'')*j8889 's   A?c                    | \  }}d}t        j                  |g      }|D ci c]  }||df	 }}d}d}t        j                  |||di|      }	t        j                  |||di|      }
|	|   j                  s*J |	|   j                  t        j                  d      k(         |
|   j                  |	|   j                  k  sJ yc c}w )	ztCheck that FancyArrowPatches with `bar` connectionstyle are also supported
    in edge label rendering. See gh-7735.rc   r   zarc3,rad=0.0zbar,fraction=0.1edgers  )r)   r   N)r>   rV  r  r  yrN  approx)ro   rs   rt   r  rK   rW   r*   	style_arc	style_bararc_lblbar_lbls              rL   #test_edge_label_bar_connectionstyler    s     GCD


D6A
 1q!f9
 C
 I"I**	3T6NIG **	3T6NIG
 4=??FGDMOOv}}X/FFF?4=??WT]__,,,! !s   C)r__doc__r   r  r  rN  networkxr>   importorskiprE   r\   userA   rcParamsbarbell_graphr  defaultsmarkparametrizerM   rX   r_   mpl_image_compareru   r   r   r   r   r   rV  r   r   r  r  r  r!  r&  r.  r7  r;  r>  rK  rQ  rY  r[  rd  rl  rr  ru  fixturero   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r&  r*  r.  r3  r6  r8  r?  rC  rF  rH  rO  rR  r  r  r[  r^  r`  rE  r   ri  rq  ru  rw  r  r  ry  r  r  r  r  r  r  r  r  rN   rL   <module>r     s^   2  	   f,'V! f-.#]  "

1a
 ,,D, ), 	,
   ," ##,$ #%,& ',( ),* D+,, #-,. )/,0 $O?S1,H #I,J #K,N sO,P aQ,R W,^ -	tXl34('  ! !H" ? ?D  : * *Z 
 "**'=> ?
* "**'=> ?( "**'=> ?>$ "**'=> ?8 "**'=> ?( 	&(>?@	
QF	1b' "**'=> ?, 	&(>?@	sCj	3* "**'=> ?4  6" z2/ 3/d 5$-0 1&P  0		*
 
#
	H%
 
f
 dVH%56D 7D 
#
	H%
 
f
 dVH%56	D 7	D6FrDD "**'=>, ?, 
a33 
a//  	55= 	. ,, 	
			s

,

,549Fz  2N
K,E6$6.8&$
( r<&89	4 :	4 /E'FGI HI(C
' z2)0 3)0\ z2) 3)X..",=D "''23C3C)DE F "''23C3C)DE	 F	 bjjlA!,r/@!.DE/	/  bjjlA!,r/@!.DE>	>( F?6 	s	b	N+	b!	b!	M	M. RWWb.>.>$?@ A t}5

$$


	9	 69-rN   