
    ިsgQ                     
   d 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<   ddlZ ej                  d	d
      Zd Zd Zd Zd Zej&                  j)                  ddddgdfddgdfddgdfddgdff	      ej&                  j)                  dddgf      d               Zej&                  j)                  ddddgdfddgdfddgdfddgdff	      ej&                  j)                  dddgf      d                Zd! Zd" Zd# Zd$ Zd% Zej&                  j)                  d&ej8                  ej:                  f      d'        Zej&                  j)                  d(d)d*gd*ff      d+        Zej&                  j)                  d(d)d*gd*ff      d,        Z ej&                  j)                  dg d-ddd.gf      d/        Z!d0 Z"d1 Z#ej&                  j)                  d2d3      d4        Z$ej&                  j)                  d5d6gd7gd8gg d9d7d:gg d;f      d<        Z%d= Z&d> Z'ej&                  jP                  d?        Z)d@ Z*dA Z+dB Z,dC Z-dD Z.dE Z/dF Z0dG Z1dH Z2dI Z3ej&                  j)                  dJdKg dLf      dM        Z4ej&                  j)                  dNdOg dPf      dQ        Z5dR Z6dS Z7ej&                  j)                  dTdU      dV        Z8ej&                  j)                  dTdU      dW        Z9dX Z:dY Z;dZ Z<d[ Z=ej&                  j)                  d\ej|                  ej~                  f      d]        Z@ej&                  j)                  d\ej|                  ej~                  f      d^        ZAd_ ZBej&                  j)                  d` ej:                         dag ej                         d	g ej                         d	gf      db        ZEej&                  j)                  d` ej:                         dag ej                         d	g ej                         d	gf      dc        ZFdd ZGde ZHdf ZIej&                  j)                  dgdNd:idJdhididjidkdlidmdlif      dn        ZJej&                  j)                  doej|                  ej                  f      dp        ZLej&                  j)                  dqddrg      ej&                  j)                  dsej~                  ej                  ej                  ej                  ej                  g      dt               ZQy)uz,Unit tests for matplotlib drawing functions.    N
matplotlibnumpyPSzmatplotlib.pyplotFztext.usetex      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)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       T/var/www/html/venv/lib/python3.12/site-packages/networkx/drawing/tests/test_pylab.py	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   
      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 0B 	BBB<B-,B<-	B96B<8B99B<c                      t        t        j                               } t        j                  t        | dt
        j                  j                  d       y )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                  R    t        j                  t        j                                y 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                     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 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Cr8   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 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]   `   sr    & 	abjj1A((	r"X*K  Dzz$$S%6%6%8(CCCDr8   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   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
,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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((CJGK[)//**EF DXzz$$S%6%6%8(CCCDr8   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   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((CJGK[*Sb/: DXzz$$S%6%6%8(CCCDr8   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 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b6S==r8   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 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"v}}r8   
graph_typec                    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.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      sx     	aj1A#CFm
,1q!f9
,C
,((C0K+t$!!n$$&!+++	 -s   A=)	edgewidthr>   r   r   r   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   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
,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   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
,1q!f9
,C
,((CyAK{q    /  "h.../ -   Brd   rb   c                    t         j                         }t        j                  |      }d}t        j                  ||| |      }t        |t        j                  |            D ]  \  }}|j                         |k(  rJ  y )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     sx     	A


1
CF((C(&QK";	0GH 5^  "n4445r8   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).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((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   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
,1q!f9
,C
, ((C0K{q    .  "g---. -s   Bstyle)dashed--rE   rE   rE   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   rX   r   r   Nr   )r   rT   rg   rM   rU   r\   s         r%   *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   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   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
,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   )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  sE   E2
"A			"**	%B


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 r8   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   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	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 )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 	 	3$! 1cA6JJtHHUOJr8   c                      t         j                         \  } }t        j                  t        |       t        j
                  t        t        j                  t              |       y )Nr   )r   r   r   drawr   r   circular_layout)r   r   s     r%   	test_axesr     s<    llnGCGGG  "*<*<W*E"Mr8   c                  V    t        j                         } t        j                  |        y r:   )r   r   r   rT   s    r%   test_empty_graphr     s    

AGGAJr8   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   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   
r34coo6T6T   !!!S2dCrIII!!!S2eDJJJ!!"cBuEKKK!!"cBtDJJJr8   c                      t        j                  dt         j                        } t        j                  | dg       t        j                  | dgg d       y )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                     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   皙?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5qQ]5E59FOOC7CF%H	LLOOOC7Cu5 6s   D	c                  V   t        j                  d      } t        j                         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   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??$
1coo6T6T(UH  x=As   %)B&B&c                     t        j                         } t        j                         j	                  d      }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   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  "  sE   
A		!	!#	&BGG	67ggi@Aa!es,@67ggi@1c!w-!+,,@	 		 __&	
!SXX]]+AJJL0AA0E 	
 61  !e7zz$$Q[[]H===1=1$%5556 A@	
s   E= FA	F
c                     t        j                         } t        j                         j	                  d      }| 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   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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   F3:F9)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)pytestraises
ValueErrorr   r   r   r<   r8   r%   test_error_invalid_kwdsr+  L  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)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  sM    


34AI	M
 ( 	Y'( ( (s   AA!r     )r(   r   r1  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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	  +yIUI. 4X#s{{::;;;%%'83334r8   r  r  r  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 )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	$ 
 {{%%22kk$$--''55M UJ/ IX#s{{::;;;#,,.h0GHHHIr8   c                  d    t        j                  t        t        j	                  ddg             y )Nr-  r.  r   )r   r   r   nparrayr<   r8   r%   test_np_edgelistr@  |  s     Wrxx0@'ABr8   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)Nr   r   r   rJ   zhas no positionr$  )r   rN   r(  r)  NetworkXErrorr   )rT   rM   s     r%   *test_draw_nodes_missing_node_from_positionrC    sT    
aA
 C	r''/@	A '
q#&' ' 's    A  A)r  )r   r  c                    t         j                         \  }}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

    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 **1cbZPQRSM"..088:3Q36BN ))	 	L !,,.6681a@M nQ////nQ////r8   c           	      :   t         j                         \  }}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 ]0  \  }}	t        d|	d|       |	d
   |d
   kD  sJ |	d   |d   k  r0J  yc c}w c c}	w )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 **1cbZPMANOAammo--/!Q7ONO ))	s)s)L AMM1Q]]_,,.ssAv6MMMNM2 1Eqdm tad{{tad{{ P Ns   -D$-Dc                     t         j                         \  } }t        j                         }|j	                  d       |j                  dd       t        j                  |ddi      d   }|j                         }|j                  dkD  r|j                  dkD  sJ t         j                  |       t         j                          y)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                     t         j                         \  } }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 t         j                  |       t         j                          yc c}w )zfEnsure 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
&1q!f9
&C
&""1cVH=a@ED::>dkkAo--KKOIIK 's   C!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.
    r4  rk   r   Nru   )r   drawingnx_pylabapply_alphaall)r   	colorlistr{   rgba_colorss       r%   test_apply_alpharh    sM     HIE**%%11)UHMK{1b5!U*+++r8   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   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    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        j	                         \  }} | ||       t        d |j                  D              sJ |j                  rJ t        j                  |       t        j                          y )Nr   r   r   c              3   d   K   | ](  }t        |t        j                  j                         * y wr:   r   rQ   r   r   .0rt   s     r%   	<genexpr>z?test_draw_networkx_arrows_default_undirected.<locals>.<genexpr>A  s!     Uz!S__;;<U   .0)
r   r   rN   r   r   anyr   r  rZ  r[  rl  r   rT   r   r   s        r%   ,test_draw_networkx_arrows_default_undirectedrv  :  sd    !
aAllnGCrUbnnUUUUzz>KKOIIKr8   c                 B   dd l }t        j                  dt        j                        }t        j                         \  }} | ||       t        d |j                  D              rJ |j                  sJ t        j                  |       t        j                          y )Nr   r   rX   r   c              3   d   K   | ](  }t        |t        j                  j                         * y wr:   ro  rp  s     r%   rr  z=test_draw_networkx_arrows_default_directed.<locals>.<genexpr>N  s&      :;
1coo445rs  )r   r   rN   rZ   r   r   rt  r   r  rZ  r[  ru  s        r%   *test_draw_networkx_arrows_default_directedry  G  sw    !
abjj1AllnGCr ?A~~    :::KKOIIKr8   c                  "   t        j                  d      } | j                  dd       t        j	                         \  }}t        j
                  | ddg|       |j                  rJ t        j                  |       t        j                          y )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  sb    
aAJJq!llnGCGGA(R0zz>KKOIIKr8   )rT   expected_n_edgesrc   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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     ?@ 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 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     ?@ 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   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
 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.r   r   N)r   rN   r   r   )rT   rg   rM   s      r%   (test_draw_networkx_edge_label_empty_dictr    sS     	aAgg
&1q!f9
&C
&''3B?2EEE 's   Ac                     t         j                         \  } }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  t         j#                  |       t         j%                          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/  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
&1q!f9
&C
&1cb8T rzz?a
 "#'"((As8*<<I RZZRS)99E ?S#||~,,S111zz$$S%6%6%8#>>>? KKOIIK# 's   Efap_only_kwargr   r  r  r   r(   r   c                 ^   t        j                  d      }|D ci c]  }|||f	 }}t        j                         \  }}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                  ||f|d	d
|  ddd       t        j                  |       t        j                          yc c}w # 1 sw Y   xY w# 1 sw Y   Dx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.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
 1q!f9
 C
 llnGC n))+,Q/J	Xj\1TU
 @ 	q#?"??@ 
	 	 	" Mg&
q#L"TL^LM
 KKOIIK# !
@ @M Ms   D:D00D#D #D,draw_fnc                 8   t         j                         \  }}t        j                  d      }t	        j
                  d      5 } | ||       d d d        t              dk(  sJ t         j                  |       t         j                          y # 1 sw Y   CxY w)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    st     llnGC
qA		 	 	- bq6Q;;KKOIIK s   BB
hide_ticksTmethodc                 ~   t        j                  d      }|j                  D ci c]  }|||f	 }}t        j	                         \  }} | ||||       |j
                  |j                  fD ]   }t        |j                               |k7  r J  t        j                  |       t        j                          y c c}w )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
&1q!f9
&C
&LLNEAr
1#"4288$ 9D'')*j8889 KKOIIK 's   B:)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   rv  ry  r{  r  r   r  r  r  r  r  r  r   r  r   rO   r   r   r  r<   r8   r%   <module>r     s^   2  	  f,'V! f-.#]  
"

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 bjjlA!,r/@!.DE/	/  bjjlA!,r/@!.DE>	>( F: 	s	b	N+	b!	b!		2 RWWb.>.>$?@	 A	 t}5

$$


			 6	r8   