
    hQ                     
   S r SSKrSSKrSSKrSSKr\R
                  " S5      r\R
                  " S5      r\R                  S5        \R
                  " S5      r	S\	R                  S'   SSKr\R                  " S	S
5      rS rS rS rS r\R&                  R)                  SSSS/S4SS/S4SS/S4SS/S44	5      \R&                  R)                  SSS/45      S 5       5       r\R&                  R)                  SSSS/S4SS/S4SS/S4SS/S44	5      \R&                  R)                  SSS/45      S  5       5       rS! rS" rS# rS$ rS% r\R&                  R)                  S&\R8                  \R:                  45      S' 5       r\R&                  R)                  S(S)S*/S*445      S+ 5       r\R&                  R)                  S(S)S*/S*445      S, 5       r \R&                  R)                  S/ S-QSSS./45      S/ 5       r!S0 r"S1 r#\R&                  R)                  S2S35      S4 5       r$\R&                  R)                  S5S6/S7/S8// S9QS7S:// S;Q45      S< 5       r%S= r&S> r'\R&                  RP                  S? 5       r)S@ r*SA r+SB r,SC r-SD r.SE r/SF r0SG r1SH r2SI r3\R&                  R)                  SJSK/ SLQ45      SM 5       r4\R&                  R)                  SNSO/ SPQ45      SQ 5       r5SR r6SS r7\R&                  R)                  STSU5      SV 5       r8\R&                  R)                  STSU5      SW 5       r9SX r:SY r;SZ r<S[ r=\R&                  R)                  S\\R|                  \R~                  45      S] 5       r@\R&                  R)                  S\\R|                  \R~                  45      S^ 5       rAS_ rB\R&                  R)                  S`\R:                  " 5       Sa/\R                  " 5       S	/\R                  " 5       S	/45      Sb 5       rE\R&                  R)                  S`\R:                  " 5       Sa/\R                  " 5       S	/\R                  " 5       S	/45      Sc 5       rFSd rGSe rHSf rI\R&                  R)                  SgSNS:0SJSh0SiSj0SkSl0SmSl045      Sn 5       rJ\R&                  R)                  So\R|                  \R                  45      Sp 5       rL\R&                  R)                  SqSSr/5      \R&                  R)                  Ss\R~                  \R                  \R                  \R                  \R                  /5      St 5       5       rQg)uz,Unit tests for matplotlib drawing functions.    N
matplotlibnumpyPSzmatplotlib.pyplotFztext.usetex      c                  2    [         R                  [         R                  [         R                  [         R                  [         R
                  [         R                  [         R                  /n SSSS./n[        R                  " X5       H'  u  p#U" [        40 UD6  [        R                  S5        M)      [        R                  " S5        g ! [         a     N$f = f! [          a     g f = f!  [        R                  " S5        f ! [          a     f f = f= f)Nblackd      )
node_color	node_sizewidthtest.ps)nxdraw_circulardraw_kamada_kawaidraw_planardraw_randomdraw_spectraldraw_spring
draw_shell	itertoolsproductbarbellpltsavefigModuleNotFoundErrorosunlinkOSError)	functionsoptionsfunctionoptions       S/var/www/html/env/lib/python3.13/site-packages/networkx/drawing/tests/test_pylab.py	test_drawr&      s      NNNNNNMM
	 #*aHI ) 1 1) EHW''KK	" !F	IIi 	  
  			IIi  		sZ   B3C 6C 
CC- CC- 
C*)C*-D/DD
DDDDc                      [        [        S5      5      [        [        SS5      5      [        [        SS5      5      /n [        R                  " [        U S9  [
        R                  S5         [        R                  " S5        g ! [         a     g f = f!  [        R                  " S5        f ! [         a     f f = f= f)Nr   
      nlistr   )
listranger   r   r   r   r   r   r   r    r*   s    r%   test_draw_shell_nlistr.   -   s    eAheArl!3T%B-5HI
gU+I	IIi  			IIi  		sB   A+B .B 
BBB>B.-B>.
B;8B>:B;;B>c                      [        [        R                  5       5      n [        R                  " [        U S[
        R                  R                  SS9  g )Nr   T)
edge_colorr   	edge_cmapwith_labels)r-   r   number_of_edgesr   r   r   cmBlues)colorss    r%   test_edge_colormapr7   9   s5    7**,-FNNF!svv||QU    c                  T    [         R                  " [        R                  5       5        g N)r   r   r   to_directed r8   r%   test_arrowsr=   A   s    NN7&&()r8   )r0   expected)Nr	   )rredr?   r@   )      ?rB   g        yellowrA   rC   )r      r   rE   limerD   rF   )#0000ffbluerG   rH   edgelistr   rE   c                     [         R                  " S5      n[         R                  " U[         R                  " U5      X S9n[        R
                  R                  UR                  5       U5      (       d   eg)z\Tests ways of specifying all edges have a single color for edges
drawn with a LineCollectionr   posrI   r0   N)r   
path_graphdraw_networkx_edgesrandom_layoutmplr6   
same_color	get_color)r0   r>   rI   Gdrawn_edgess        r%   !test_single_edge_color_undirectedrV   F   s\    & 	aA((	r"XK ::  !6!6!8(CCCCr8   c                    [         R                  " S[         R                  S9n[         R                  " U[         R                  " U5      X S9nU H8  n[
        R                  R                  UR                  5       U5      (       a  M8   e   g)z]Tests ways of specifying all edges have a single color for edges drawn
with FancyArrowPatchesr   create_usingrL   N)	r   rN   DiGraphrO   rP   rQ   r6   rR   get_edgecolor)r0   r>   rI   rT   rU   faps         r%   test_single_edge_color_directedr]   `   sl    & 	abjj1A((	r"XK zz$$S%6%6%8(CCCC r8   c                  h   [         R                  " S[         R                  S9n [        [	        U 5      5       Vs0 s H  oX4_M     nnS H  n[         R
                  " XUS9nU H8  n[        R                  R                  UR                  5       U5      (       a  M8   e   [         R
                  " XSS/US9nU H8  n[        R                  R                  UR                  5       U5      (       a  M8   e   M     [         R
                  " X/ SQS	S9nU H8  n[        R                  R                  UR                  5       S
5      (       a  M8   e   [         R
                  " X/ SQSS9nU H8  n[        R                  R                  UR                  5       S
5      (       a  M8   e   [         R
                  " X/ SQSS9n[        R                  R                  US   R                  5       US   R                  5       5      (       d   eU H8  n[        R                  R                  UR                  5       S
5      (       d  M8   e   [         R
                  " X/ SQS	S9n[        R                  R                  US   R                  5       US   R                  5       5      (       d   e[        R                  R                  US   R                  5       US   R                  5       5      (       d   eU H8  n[        R                  R                  UR                  5       S
5      (       d  M8   e   gs  snf )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   rX   )r   r   rE   r   r   rE   rE   r0   rJ   rE      )rI   r0   rJ   rb   rc   r   r`   rH   )rJ   rb   re   )r   r   r_   r   rE   rc   r   N)
r   rN   rZ   r-   lenrO   rQ   r6   rR   r[   )rT   nrM   ecrU   r\   s         r%   $test_edge_color_tuple_interpretationri   {   s    	abjj1A#CFm
,mqf9mC
, (,,QCC::(():):)<bAAAA  ,,ff-"
 C::(():):)<bAAAA  ( ((	1lK zz$$S%6%6%8&AAAA  ((	9iK zz$$S%6%6%8&AAAA  ((	1iK ::  A$$&A(D(D(F    ::(():):)<fEEEE  ((	9lK ::  A$$&A(D(D(F    ::  A$$&A(D(D(F    ::(():):)<fEEEE c -s   L/c                  J   [         R                  5       n [        R                  " [         5      nSn[        R                  " XUS9n[        U[        R                  " U5      5       H:  u  pE[        R                  R                  UR                  5       U5      (       a  M:   e   g)zVTest that the edge colors are cycled when there are fewer specified
colors than edges.r?   gbra   N)r   r;   r   rP   rO   zipr   cyclerQ   r6   rR   r[   rT   rM   
edgecolorsrU   r\   r>   s         r%   .test_fewer_edge_colors_than_num_edges_directedrr      s|     	A


7
#C J((JGK[)//**EFzz$$S%6%6%8(CCCC Gr8   c                  D   [         R                  " S[         R                  S9n [         R                  " [        5      nSn[         R
                  " XUS9n[        X2SS 5       H:  u  pE[        R                  R                  UR                  5       U5      (       a  M:   e   g)zXTest that extra edge colors are ignored when there are more specified
colors than edges.r   rX   )r?   rl   rm   cra   N)r   rN   rZ   rP   r   rO   rn   rQ   r6   rR   r[   rp   s         r%   -test_more_edge_colors_than_num_edges_directedrv      s|     	abjj1A


7
#C%J((JGK[Sb/:zz$$S%6%6%8(CCCC ;r8   c                  T   [         R                  " [        [         R                  " [        5      SS/SSS9n U R	                  5       R                  5       n[        U R                  5       5      S:X  d   e[        R                  R                  US S S5      (       d   eUS   S:X  d   eg NrJ   rb   purple皙?)rM   rI   r0   alpharc   ru   )r   rO   r   rP   rS   squeezerf   	get_pathsrQ   r6   rR   )edge_collectionrh   s     r%   3test_edge_color_string_with_global_alpha_undirectedr      s    ,,W%&!O 
	"	"	$	,	,	.B((*+q000::  CR(3333b6S==r8   c                  J   [         R                  " [        R                  5       [         R                  " [        5      SS/SSS9n [        U 5      S:X  d   eU  HH  nUR                  5       n[        R                  R                  US S S5      (       d   eUS   S:X  a  MH   e   g rx   )
r   rO   r   r;   rP   rf   r[   rQ   r6   rR   )rU   r\   rh   s      r%   1test_edge_color_string_with_global_alpha_directedr      s    ((W%&!K {q    zz$$RWh7777"v}} r8   
graph_typec                    [         R                  " SU S9n[        [        U5      5       Vs0 s H  o"X"4_M     nn[         R                  " X5      n[        U[        5      (       a  US   nUR                  5       S:X  d   egs  snf )zZTest the default linewidth for edges drawn either via LineCollection or
FancyArrowPatches.rc   rX   r   rE   N)r   rN   r-   rf   rO   
isinstancer,   get_linewidth)r   rT   rg   rM   rU   s        r%   test_edge_width_default_valuer      sv     	aj1A#CFm
,mqf9mC
,((0K+t$$!!n$$&!+++	 -s   B)	edgewidthr>   r   r   r   c                    [         R                  " S5      n[        [        U5      5       Vs0 s H  o3X34_M     nn[         R                  " X$U S9n[        UR                  5       5      S:X  d   eUR                  5       U:X  d   eg s  snf )Nr   r   r   )r   rN   r-   rf   rO   r}   r   )r   r>   rT   rg   rM   rU   s         r%   'test_edge_width_single_value_undirectedr      s|     	aA#CFm
,mqf9mC
,((yAK{$$&'1,,,$$&(222 -s   Bc                 (   [         R                  " S[         R                  S9n[        [	        U5      5       Vs0 s H  o3X34_M     nn[         R
                  " X$U S9n[	        U5      S:X  d   eU H  nUR                  5       U:X  a  M   e   g s  snf )Nr   rX   r   r   )r   rN   rZ   r-   rf   rO   r   )r   r>   rT   rg   rM   rU   r\   s          r%   %test_edge_width_single_value_directedr     s     	abjj1A#CFm
,mqf9mC
,((yAK{q     "h...  -   Brd   rb   c                    [         R                  5       n[        R                  " U5      nSn[        R                  " XXS9n[        U[        R                  " U5      5       H  u  pVUR                  5       U:X  a  M   e   g )N)      ?       @g      (@)rI   r   )	r   r;   r   rP   rO   rn   r   ro   r   )rI   rT   rM   widthsrU   r\   expected_widths          r%   test_edge_width_sequencer     sn     	A


1
CF(((QK";	0GH  "n444  Ir8   c                     [         R                  " S[         R                  S9n [         R                  " U 5      n[         R                  " XSS/S9nU Vs/ s H  o3R                  5       PM     nn[         R                  " XSS/SSS9nU Vs/ s H  o3R                  5       PM     nn[        R                  R                  XE5      (       d   eg	s  snf s  snf )
zuTest that edge_vmin and edge_vmax properly set the dynamic range of the
color map when num edges == len(edge_colors).r   rX   r   rB   ra   rz   g?)r0   	edge_vmin	edge_vmaxN)	r   rN   rZ   rP   rO   r[   rQ   r6   rR   )rT   rM   rU   eorig_colorsscaled_colorss         r%   #test_edge_color_with_edge_vmin_vmaxr   #  s     	abjj1A


1
C((QHEK.9:k??$kK:((	C:K 1<<1__&M<::  <<<< ;
 =s   CCc                  *   [         R                  " S[         R                  S9n [        [	        U 5      5       Vs0 s H  oX4_M     nn[         R
                  " X5      n[	        U5      S:X  d   eU H  nUR                  5       S:X  a  M   e   gs  snf )z>Test default linestyle for edges drawn with FancyArrowPatches.r   rX   r   solidNr   rN   rZ   r-   rf   rO   get_linestyle)rT   rg   rM   rU   r\   s        r%   %test_directed_edges_linestyle_defaultr   3  s    
abjj1A#CFm
,mqf9mC
, ((0K{q     "g---  -s   Bstyle)dashed--rE   rE   rE   c                 (   [         R                  " S[         R                  S9n[        [	        U5      5       Vs0 s H  o"X"4_M     nn[         R
                  " XU S9n[	        U5      S:X  d   eU H  nUR                  5       U :X  a  M   e   gs  snf )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   rX   r   r   Nr   )r   rT   rg   rM   rU   r\   s         r%   *test_directed_edges_linestyle_single_valuer   ?  s     	abjj1A#CFm
,mqf9mC
,((u=K{q     "e+++ 	 -r   	style_seqr   r   r   )r   -:r   )r   r   r   z-.c                 h   [         R                  " S[         R                  S9n[        [	        U5      5       Vs0 s H  o"X"4_M     nn[         R
                  " XU S9n[	        U5      S:X  d   e[        U[        R                  " U 5      5       H  u  pVUR                  5       U:X  a  M   e   gs  snf )zTests support for specifying linestyles with sequences in
``draw_networkx_edges`` for FancyArrowPatch outputs (e.g. directed edges).r   rX   r   r   N)
r   rN   rZ   r-   rf   rO   rn   r   ro   r   )r   rT   rg   rM   rU   r\   r   s          r%   &test_directed_edges_linestyle_sequencer   U  s     	abjj1A#CFm
,mqf9mC
,((yAK{q   +yy'AB
  "e+++ C	 -s   B/c                  :   SSK Jn Jn  SSKJn  [
        R                  " [
        R                  5      n[
        R                  " [
        R                  5      n[
        R                  " U5      n[
        R                  " U5      n[
        R                  " X55      n[        Xq5      (       d   e[
        R                  " XFSS9n[        U[        5      (       d   e[        U5      S:  a  [        US   U5      (       d   e[
        R                  " XFSS9n[        X5      (       d   e[
        R                  " X6S S9n[        X5      (       d   e[
        R                  " XES S9n[        U[        5      (       d   e[        U5      S:  a  [        US   U5      (       d   eg g )Nr   )LineCollectionPathCollection)FancyArrowPatchTarrowsF)matplotlib.collectionsr   r   matplotlib.patchesr   r   cubical_graphGraphrZ   spring_layoutdraw_networkx_nodesr   rO   r,   rf   )	r   r   r   rT   dGrM   dposnodesedgess	            r%   test_return_typesr   m  sJ   E2
"A			"**	%B


1
CBD""1*Ee,,,,""2D9EeT""""
5zA~%(O4444""2E:Ee,,,,""148Ee,,,,""248EeT""""
5zA~%(O4444 r8   c                     [         R                  " 5       n [         R                  " U 5      n[         R                  " X/ SQSSSS9  [         R                  " U U/ SQSS/ SQS9  [         R                  " XS	S
S9  [         R                  " U U/ SQSS
SS9  [         R                  " U U/ SQSS
SS9  [         R                  " U U/ SQSS
SSSS9  0 nSUS'   SUS'   SUS'   SUS'   SUS'   SUS'   SUS'   S US!'   [        S5       Vs0 s H  o3US-  S:X  a  S"OS_M     nn[         R                  " XUS#S$9  [         R                  " XUS#US%9  [         R                  " XS S&S'9  [         R                  " XS(S)0S*9  g s  snf )+Nr   rE   rc   r   r?   i        ?)nodelistr   r   r{   )r      r      rm   )g      ?r   r   rB   rB   r   )r   r{   )rJ   rb   re   )r   r      )rI   r   r{   r0   )r   r   )r   r   )r   r   )r   r   T)rI   r   min_source_marginmin_target_marginr   r0   z$a$r   z$b$rE   z$c$rc   z$d$r   z$\alpha$r   z$\beta$r   z$\gamma$r   z$\delta$r   k   )	font_size)r   
font_colorF)edge_labelsrotater   z4-5r   )r   r   r   r   rO   r-   draw_networkx_labelsdraw_networkx_edge_labels)rT   rM   labelsrg   r6   s        r%   test_labels_and_colorsr     s   
A


1
C	#D 	$ 1C8	1 	1 	1	 FF1IF1IF1IF1IF1IF1IF1IF1I5:1X>XA
+XF>AFb9AFbVL  T%H  fe_E	 ?s   E7c                  p   [         R                  " 5       n [        R                  5       u  pSSSSSS.n[         R                  " U US/ SQS	S
9  [         R                  " XSS/SS
9  [         R
                  " XSSS9  UR                  S5        [        R                  5         [        R                  S5        U$ )Nr   r   rE   r   rJ   r   )r   r   )r   rE   rc   r   r   i  r   ztab:blue)r   r   r   i  r   z
tab:oranger   r   )r{   r   g)\(?off)	r   house_graphr   subplotsr   rO   marginstight_layoutaxis)rT   figaxrM   s       r%   test_house_with_colorsr     s    
AllnGCFv*
EC 	 	$! 1A6JJtHHUOJr8   c                      [         R                  5       u  p[        R                  " [        US9  [        R
                  " [        [        R                  " [        5      US9  g )Nr   )r   r   r   drawr   r   circular_layout)r   r   s     r%   	test_axesr     s:    llnGCGGG  "*<*<W*E"Mr8   c                  Z    [         R                  " 5       n [         R                  " U 5        g r:   )r   r   r   rT   s    r%   test_empty_graphr     s    

AGGAJr8   c                  p   SS K n [        R                  " SS/5      n[        R                  " SS/5      n[        R                  " U5      n[        [        R                  " X/ S9[        R                  R                  5      (       d   e[        [        R                  " X#/ S9[        R                  R                  5      (       d   e[        R                  " X/ SS9/ :X  d   e[        R                  " X/ SS9/ :X  d   e[        R                  " X#/ SS9/ :X  d   e[        R                  " X#/ SS9/ :X  d   eg )Nr   rb   re   )r   T)rI   r   F)r   r   r   rZ   r   r   r   rQ   collectionsr   rO   )r   rT   DGrM   s       r%   #test_draw_empty_nodes_return_valuesr     s   !
&&!"A	VV$	%B


Q
C
q3S__5S5S    
r4coo6T6T    !!!2dCrIII!!!2eDJJJ!!"BuEKKK!!"BtDJJJr8   c                      [         R                  " S[         R                  S9n [         R                  " U S/S9  [         R                  " U S// SQS9  g )Nr   rX   )r   rE   r   rI   )r(      r   )rI   r   )r   rN   MultiDiGraphdraw_networkxr   s    r%   test_multigraph_edgelist_tuplesr     s<    
aboo6AQ)-Q)Dr8   c                     [         R                  " [        5      n [        R	                  5       nUR                  S5        [         R                  " [        U SS/S9  [        [        R                  5      n[        U5       Vs/ s H  o3U-  PM	     nn[        U5      nUR                  S5        [         R                  " [        XUS9  UR                  S5        UR                  S5        [         R                  " [        XS9  g s  snf )	N   皙?rz   )r{      )r   r{   rE      )r   rP   r   r   figureadd_subplotr   rf   r   r-   append)rM   r   	num_nodesxr{   r6   s         r%   test_alpha_iterr     s    


7
#C
**,COOC7CSz:GMM"I$))$45$4q]$4E59FOOC7C%H	LLOOOC7C5 6s   Dc                  h   [         R                  " S5      n [        R                  5       R	                  S5      n[         R
                  " U / SQUS9  UR                  5        Vs/ s H0  n[        U[        R                  R                  5      (       d  M.  UPM2     nn[        U5      S:X  d   eg s  snf )Nr   o   )ohs^)
node_shaper   )r   rN   r   r   r   r   get_childrenr   rQ   r   r   rf   )rT   r   r  scatterss       r%   test_multiple_node_shapesr    s    
aA		!	!#	&BGGA.26??$$a
1coo6T6T(U$   x=As   $-B/B/c                  Z   [         R                  " 5       n [        R                  5       R	                  S5      n[         R
                  " U UU R                  5        Vs0 s H  o"US-  (       a  SOS_M     snU R                  5        Vs0 s H  o"[        US-  S-   5      _M     snS9  [        U R                  5       UR                  5        Vs/ s HO  n[        U[        R                  R                  5      (       d  M.  [        UR                  5       5      S:  d  MM  UPMQ     sn5       Hm  u  p#US-  (       a  S	OS
n[        R                   R#                  UR%                  5       U5      (       d   e[        US-  S-   5      UR'                  5       :X  a  Mm   e   g s  snf s  snf s  snf )Nr   rc   r   r?   g""""""@r   )r   r   r   r   r	   r@   )r   karate_club_graphr   r   r   r   r   intrn   r  r   rQ   textTextrf   get_textr6   rR   rS   get_size)rT   r   rg   tr>   s        r%   #test_individualized_font_attributesr  "  sP   
A		!	!#	&BGG	67ggi@ia!es,i@67ggi@ic!w-!+,,i@	 		 __&	
&!SXX]]+ 03AJJL0AA0E &	
  !e7zz$$Q[[]H====1=1$%555 A@	
s   F	F#-F(
 F(
F(
c                     [         R                  " 5       n [        R                  5       R	                  S5      nU R                  5        VVs/ s H  u  p#X#-   S-  S:X  a  SOSPM     nnnU R                  5        VVs/ s H  u  p#SUS-  US-  -   -  S-   PM     nnn[         R                  " XSXES9  UR                  5        Vs/ s H0  n[        U[        R                  R                  5      (       d  M.  UPM2     nn[        U R                  5       U5       H  u  pU	R                  5       SUS   S-  US	   S-  -   -  S-   :X  d   e[        U5      S-  (       a$  [        R                  R                  R                   O#[        R                  R                  R"                  n
[        U	R%                  5       U
5      (       a  M   e   g s  snnf s  snnf s  snf )
Nr   rc   r   -|>-[r(   T)r   r   
arrowstyle	arrowsizerE   )r   r  r   r   r   r   r   r  r   rQ   patchesr   rn   get_mutation_scalesum
ArrowStyleBracketBCurveFilledBget_arrowstyle)rT   r   uvarrowstyles
arrowsizesfr   r   ar>   s              r%   #test_individualized_edge_attributesr"  9  s   
A		!	!#	&BCD779M941QUaK1,5$69KM89	B	"AA&+	JBGGATkP??$$a
1ckk6Q6Q(R$   AGGIv&##%qtax!A$(/B)Cb)HHHH 1vz KK""++''44 	
 !**,h7777 ' NBs   G	=G-G6Gc                      [         R                  " [        SS9   [        R                  " [
        SS9  S S S 5        g ! , (       d  f       g = f)NzReceived invalid argumentmatchbar)foo)pytestraises
ValueErrorr   r   r   r<   r8   r%   test_error_invalid_kwdsr+  L  s,    	z)D	E
U# 
F	E	Es	   =
Ac                      [         R                  " / SQ5      n / SQn[        R                  " [        SS9   [         R
                  " XS9  S S S 5        g ! , (       d  f       g = f)N)rJ   r   rc   r   r   rE   r   )rE   rc   r   z1arrowsize should have the same length as edgelistr$  )r  )r   rZ   r(  r)  r*  r   )rT   r  s     r%   +test_draw_networkx_arrowsize_incorrect_sizer0  Q  sF    


34AI	M
 	'
 
 
s   A
A"r     )r(   r   r1  c                 n   [         R                  " / SQ5      nSSSS.n[         R                  " XU S9n[        U [        5      (       a  [
        R                  " U 5      OU n [        X05       HF  u  pE[        U[        R                  R                  5      (       d   eUR                  5       U:X  a  MF   e   g )NrJ   r-  rb   r   rJ   r   r   rE   rc   )rM   r  )r   rZ   rO   r   r	  r   repeatrn   rQ   r  r   r  )r  rT   rM   r   r\   r>   s         r%   test_draw_edges_arrowsizer6  Z  s    


+,AF
+C""1CE/9)S/I/I	  +yIU.#s{{::;;;;%%'8333 /r8   r  r  r  r  z<|-|>c                 `   [         R                  " / SQ5      nSSSS.n[         R                  " XU S9n[        U [        5      (       a  [
        R                  " U 5      OU n [        R                  R                  R                  [        R                  R                  R                  [        R                  R                  R                  S.n[        X05       HS  u  pV[        U[        R                  R                  5      (       d   e[        UR                  5       XF   5      (       a  MS   e   g )Nr3  r   rJ   r   r4  )rM   r  r7  )r   rZ   rO   r   strr   r5  rQ   r  r  r  r  CurveFilledABrn   r   r  )r  rT   rM   r   arrow_objectsr\   r>   s          r%   test_draw_edges_arrowstyler<  g  s    


+,AF
+C""1*EE )3:s(C(C	$ 
 {{%%22kk$$--''55M U/#s{{::;;;;#,,.0GHHHH 0r8   c                  `    [         R                  " [        [        R	                  SS/5      S9  g )Nr-  r.  r   )r   r   r   nparrayr<   r8   r%   test_np_edgelistr@  |  s     Wrxx0@'ABr8   c                      [         R                  " S5      n SSS.n[        R                  " [         R                  SS9   [         R
                  " X5        S S S 5        g ! , (       d  f       g = f)Nr   r   r   rJ   zhas no positionr$  )r   rN   r(  r)  NetworkXErrorr   )rT   rM   s     r%   *test_draw_nodes_missing_node_from_positionrC    sJ    
aA
 C	r''/@	A
q& 
B	A	As   A
A-r  )r   r  c           	         [         R                  5       u  p[        R                  " S/5      nSSS.n[        R                  " X4X S9S   nUR                  5       R                  5       SSS2S4   n[        R                  " UUUU SSS	9S   nUR                  5       R                  5       SSS2S4   nUS   US   :  d   eUS
   US
   :  d   eg)  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

rJ   r   r   r   r  r   Nrc   r
   r   r  r   r   rE   )r   r   r   rZ   rO   get_extentscorners)	r  r   r   rT   rM   default_patchdefault_extentpadded_patchpadded_extents	            r%   )test_draw_edges_min_source_target_marginsrN    s    & llnGC


F8A
 C **1bPQRSM"..088:3Q36BN ))	 	L !,,.6681a@M nQ////nQ////r8   c           	      >   [         R                  5       u  p[        R                  " SS/5      nSSSS.n[        R                  " X4X S9nU Vs/ s H(  ofR                  5       R                  5       SSS	2S
4   PM*     nn[        R                  " UUUU SS/SS/S9nU V	s/ s H(  oR                  5       R                  5       SSS	2S
4   PM*     n
n	[        Xz5       H4  u  pi[        SU	< SU< 35        U	S
   US
   :  d   eU	S   US   :  a  M4   e   gs  snf s  sn	f )rE  rJ   rb   r   r   )rc   r   r4  rF  Nrc   r   b   f   rG  zp=z, d=rE   )	r   r   r   rZ   rO   rH  rI  rn   print)r  r   r   rT   rM   rJ  drK  rL  prM  s              r%   4test_draw_edges_min_source_target_margins_individualrU    s+   & llnGC


FF#$AF
+C **1bPMANOAmmo--/!Q7NO ))	s)s)L AMM1]]_,,.ssAv6MMN2Eqdm tad{{tad{{ 3 P Ns   /D /Dc                     [         R                  5       u  p[        R                  " 5       nUR	                  S5        UR                  SS5        [        R                  " USS05      S   nUR                  5       nUR                  S:  a  UR                  S:  d   e[         R                  U5        [         R                  5         g)zDEnsure that selfloop extent is non-zero when there is only one node.r   r   N)r   r   r   rZ   add_nodeadd_edgerO   rH  r   heightdelaxesclose)r   r   rT   patchbboxs        r%   &test_nonzero_selfloop_with_single_noder^    s     llnGC


AJJqMJJq!""1q&k215ED::>dkkAo--KKOIIKr8   c                     [         R                  5       u  p[        R                  " S[        R                  S9nUR                  SS5        UR                   Vs0 s H  o3X34_M     nn[        R                  " X$S/S9S   nUR                  5       nUR                  S:  a  UR                  S:  d   e[         R                  U5        [         R                  5         gs  snf )z^Ensure that selfloop extent is non-zero when only a single edge is
specified in the edgelist.
rc   rX   rE   r   r   r   N)r   r   r   rN   rZ   rX  r   rO   rH  r   rY  rZ  r[  )r   r   rT   rg   rM   r\  r]  s          r%   2test_nonzero_selfloop_with_single_edge_in_edgelistr`    s    
 llnGC
abjj1AJJq!gg
&gqf9gC
&""1VH=a@ED::>dkkAo--KKOIIK 's   Cc                      / SQn / SQnSn[         R                  R                  R                  XU 5      n[	        USS2S4   U:H  5      (       d   eg)z^Test apply_alpha when there is a mismatch between the number of
supplied colors and elements.
r4  rk   r   Nru   )r   drawingnx_pylabapply_alphaall)r   	colorlistr{   rgba_colorss       r%   test_apply_alpharh    sN     HIE**%%11)HMK{1b5!U*++++r8   c                  ~   SSK n SSKn [        R                  " S5      n[        R                  " S[        R                  S9nU Vs0 s H  o3X34_M     nnX4 Hj  n[        R
                  " XTSS9n[        U5      [        UR                  5      :X  d   e[        US   [        R                  R                  5      (       a  Mj   e   X4 HC  n[        R
                  " XTSS9n[        U[        R                  R                  5      (       a  MC   e   [        R
                  " X5      n[        U[        R                  R                  5      (       d   e[        R
                  " X$5      n[        U5      [        WR                  5      :X  d   e[        US   [        R                  R                  5      (       d   egs  snf )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   Nr   rX   Tr   F)r   r   r   rN   rZ   rO   rf   r   r   rQ   r  r   r   r   )r   UGr   rg   rM   rT   r   s          r%   *test_draw_edges_toggling_with_arrows_kwargrk    s[    "	q	B	qrzz	2B 
!bqf9bC
! X&&qd;5zS\)))%(CKK$?$?@@@@  X&&qe<%!?!?@@@@ 
 ""2+EeS__;;<<<<""2+Eu:QWW%%%eAh ; ;<<<<% "s   F:drawing_funcc                 .   SS K n[        R                  " S5      n[        R	                  5       u  p4U " X$S9  [        S UR                   5       5      (       d   eUR                  (       a   e[        R                  U5        [        R                  5         g )Nr   r   r   c              3   j   #    U  H)  n[        U[        R                  R                  5      v   M+     g 7fr:   r   rQ   r   r   .0rt   s     r%   	<genexpr>?test_draw_networkx_arrows_default_undirected.<locals>.<genexpr>A  s$     Unz!S__;;<<n   13)
r   r   rN   r   r   anyr   r  rZ  r[  rl  r   rT   r   r   s        r%   ,test_draw_networkx_arrows_default_undirectedrw  :  sc    !
aAllnGCUbnnUUUUUzz>KKOIIKr8   c                 H   SS K n[        R                  " S[        R                  S9n[        R                  5       u  p4U " X$S9  [        S UR                   5       5      (       a   eUR                  (       d   e[        R                  U5        [        R                  5         g )Nr   r   rX   r   c              3   j   #    U  H)  n[        U[        R                  R                  5      v   M+     g 7fr:   ro  rp  s     r%   rr  =test_draw_networkx_arrows_default_directed.<locals>.<genexpr>N  s'      ?M!
1coo4455~rt  )r   r   rN   rZ   r   r   ru  r   r  rZ  r[  rv  s        r%   *test_draw_networkx_arrows_default_directedr{  G  sx    !
abjj1AllnGC ?A~~     :::KKOIIKr8   c                  (   [         R                  " S5      n U R                  SS5        [        R	                  5       u  p[         R
                  " U SS/US9  UR                  (       a   e[        R                  U5        [        R                  5         g )Nr   r   rJ   rb   )rI   r   )	r   rN   rX  r   r   r   r  rZ  r[  )rT   r   r   s      r%   test_edgelist_kwarg_not_ignoredr}  V  s`    
aAJJq!llnGCGGA(R0zz>KKOIIKr8   )rT   expected_n_edgesrc   c           	      6   [        / SQ5       H%  u  nu  p4U R                  X4[        US-  S5      S9  M'     U  Vs0 s H  oUXU4_M     nnSSS// SQ4 H>  n[        R                  " XUS9  [        R                  " XUS9n[        U5      U:X  a  M>   e   gs  snf )	zGDraws edges correctly for 3 types of graphs and checks for valid lengthrJ   rJ   rJ   r-  r   rc   weightarc3,rad=0.1)r  r  arc3,rad=0.2connectionstyleN)	enumeraterX  roundr   rO   rf   )	rT   r~  ir  r  rg   rM   
conn_styler   s	            r%   2test_draw_networkx_edges_multiedge_connectionstyler  a  s     ?@	6A	

1a!eQ
0 A
 aqf9aC
  		(8

 	qzB''
K6{.... !s   Bc           	         [        / SQ5       H%  u  nu  p4U R                  X4[        US-  S5      S9  M'     U  Vs0 s H  oUXU4_M     nn[        R                  " X/ SQS9nSSS// SQ4 H\  n[        R
                  " XUS9n	[        U	5      U:X  d   eU	R                  5        H  n
U
R                  R                  S	:X  a  M   e   M^     g
s  snf )zXDraws labels correctly for 3 types of graphs and checks for valid length and class namesr  r   rc   r  )r  r  r  r  r  r  CurvedArrowTextN)
r  rX  r  r   rO   r   rf   values	__class____name__)rT   r~  r  r  r  rg   rM   r   r  
text_itemstis              r%   8test_draw_networkx_edge_labels_multiedge_connectionstyler  u  s     ?@	6A	

1a!eQ
0 A
 aqf9aC
 ##	 PF 		(8

 11!*U
:"2222##%B<<((,==== & !s   Cc                  $   [         R                  " 5       n U R                  SSSS9  U R                  SSSS9  [         R                  " U S5      nU  Vs0 s H  o"X"4_M     nn[         R                  " U UUSS/S	9n[        U5      S
:X  d   eg s  snf )Nr   rE   r(   r  r   r  r  r  )r   r  rc   )r   
MultiGraphrX  get_edge_attributesr   rf   )rT   r   rg   rM   r  s        r%   'test_draw_networkx_edge_label_multiedger    s    
AJJq!BJJJq!BJ((H5K
 aqf9aC
 --	'8	J z?a !s   Bc                      [         R                  " S5      n U R                   Vs0 s H  oX4_M     nn[         R                  " X0 S90 :X  d   egs  snf )zKRegression test for draw_networkx_edge_labels with empty dict. See
gh-5372.r   r   N)r   rN   r   r   )rT   rg   rM   s      r%   (test_draw_networkx_edge_label_empty_dictr    sN     	aAgg
&gqf9gC
&''B?2EEE 's   Ac                     [         R                  5       u  p/ SQn/ SQn[        R                  " U5      nUR                   Vs0 s H  oUXU4_M     nn[        R
                  " XFXUS9  [        UR                  5      S:X  d   e[        R                  USS 5      [        R                  SS/5      -   n[        UR                  USS U5       Ha  u  pn
UR                  5       R                  U
5      (       d   e[        R                  R                  UR!                  5       U	5      (       a  Ma   e   [         R#                  U5        [         R%                  5         gs  snf )	zpWhen an edgelist is supplied along with a sequence of colors, check that
the self-loops have the correct colors.)r/  rb   re   r   r   )rc   rc   )pinkcyanr	   r@   rH   green)r   rI   r0   r   Nr   r   )r   r   r   r   r   rO   rf   r  r>  r?  rn   get_pathcontains_pointrQ   r6   rR   r[   rZ  r[  )r   r   rI   edge_colorsrT   rg   rM   	sl_pointsr\   clrslps              r%   3test_draw_networkx_edges_undirected_selfloop_colorsr    s    llnGC?HCK
Agg
&gqf9gC
&1bT rzz?a
 "#'"((As8*<<I RZZRS)99E#||~,,S1111zz$$S%6%6%8#>>>> F KKOIIK# 's   Efap_only_kwargr   r  r  r   r(   r   c                 t   [         R                  " S5      nU Vs0 s H  o"X"4_M     nn[        R                  5       u  pE[	        U R                  5       5      S   n[        R                  " [        SU S3S9   [         R                  " X4SU0U D6  SSS5        [        R                  " 5          [        R                  " S5        [         R                  " X4US	S
.U D6  SSS5        [        R                  U5        [        R                  5         gs  snf ! , (       d  f       N= f! , (       d  f       NN= f)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.r   r   z

The z# keyword argument is not applicabler$  r   NerrorT)r   r   )r   rN   r   r   r,   keysr(  warnsUserWarningrO   warningscatch_warningssimplefilterrZ  r[  )r  rT   rg   rM   r   r   
kwarg_names          r%   1test_user_warnings_for_unused_edge_drawing_kwargsr    s     	aA
 aqf9aC
 llnGC n))+,Q/J	Xj\1TU
 	q?"??
 
	 	 	"g&
qL"TL^L 
#
 KKOIIK# !

 
 
#	"s   D9D01D)
D&)
D7draw_fnc                 8   [         R                  5       u  p[        R                  " S5      n[        R
                  " SS9 nU " X2S9  S S S 5        [        W5      S:X  d   e[         R                  U5        [         R                  5         g ! , (       d  f       NI= f)Nr   T)recordr   r   )	r   r   r   cycle_graphr  r  rf   rZ  r[  )r  r   r   rT   ws        r%   *test_no_warning_on_default_draw_arrowstyler    si     llnGC
qA		 	 	- 
.q6Q;;KKOIIK 
.	-s   B
B
hide_ticksTmethodc                 |   [         R                  " S5      nUR                   Vs0 s H  o3X34_M     nn[        R	                  5       u  pVU " X$XaS9  UR
                  UR                  4 H"  n[        UR                  5       5      U:w  a  M"   e   [        R                  U5        [        R                  5         g s  snf )Nr   )rM   r   r  )r   rN   r   r   r   xaxisyaxisboolget_ticklabelsrZ  r[  )r  r  rT   rg   rM   _r   r   s           r%   test_hide_ticksr    s     	aAgg
&gqf9gC
&LLNEA
1"4288$D'')*j888 % KKOIIK 's   B9)R__doc__r   r   r  r(  importorskiprQ   r>  user   rcParamsnetworkxr   barbell_graphr   r&   r.   r7   r=   markparametrizerV   r]   ri   rr   rv   r   r   r   rZ   r   r   r   r   r   r   r   r   r   r   mpl_image_comparer   r   r   r   r   r   r  r  r"  r+  r0  r6  r<  r@  rC  rN  rU  r^  r`  rh  rk  r   r   rw  r{  r}  r  r   r  r  r  r  r  r  r   r  r   rO   r   r   r  r<   r8   r%   <module>r     sJ   2  	  ,'! -.#]  


1a
 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*Z$(,=D "''23C3C)DE	 F	 "''23C3C)DE F jjlA!,r/@!.DE/	/  jjlA!,r/@!.DE>	>( F: 	s	b	N+	b!	b!		2 RWWb.>.>$?@	 A	 t}5

$$


			 6	r8   