+
    )i\                        R t ^ RIt^ RIt]P                  ! R4      t]P                  ! R4        ! R R4      tR tR tR t	]P                  P                  R	]! ^^4      4      R
 4       tR tR tR tR t]P                  P                  R]P$                  ]P&                  ]P(                  ]P*                  ]P,                  ]P.                  ]P0                  ]P2                  ]P4                  .	4      R 4       t]P                  P                  RRR.4      ]P                  P                  R/ R^ R/R^ ./R^/.4      R 4       4       tR# )z Unit tests for layout functions.Nnumpyscipyc                     a  ] tR t^t o ]R 4       tR tR tR tR t	R t
R tR tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t R t!R t"R t#R  t$R! t%R" t&R# t'R$ t(R%t)V t*R&# )'
TestLayoutc                    \         P                  ! ^^4      V n        \         P                  ! 4       V n        \         P
                  ! V P                  R4       \         P                  ! ^^4      V n        R# )   abcdefN)nxgrid_2d_graphGiGraphGsadd_pathbigG)clss   &`/var/www/html/photoedit/myenv/lib/python3.14/site-packages/networkx/drawing/tests/test_layout.pysetup_classTestLayout.setup_class   sI    !!!Q'
CFFH%##B+    c                h  aa \         P                  ! ^4      p\        P                  ! \        RR7      ;_uu_ 4        \         P
                  ! V^ .R7       RRR4       ^ R	^R
/o\        P                  ! \        RR7      ;_uu_ 4        \         P
                  ! V^ ^.SR7       RRR4       \         P
                  ! V^ ^.SR7      o\        ;QJ d     VV3R lR 4       F  '       d   K   RM	  RM! VV3R lR 4       4      '       g   Q hR#   + '       g   i     L; i  + '       g   i     L; i)   z!nodes are fixed without positionsmatch)fixedN)r   posc              3   l   <"   T F)  p\         P                  SV,          SV,          4      x  K+  	  R # 5iN)nparray_equal).0noutr   s   & r   	<genexpr>;TestLayout.test_spring_fixed_without_pos.<locals>.<genexpr>    s'     B6a2>>#a&#a&116s   14FT   r%       r'   r'      )r	   
path_graphpytestraises
ValueErrorspring_layoutall)selfGr!   r   s   & @@r   test_spring_fixed_without_pos(TestLayout.test_spring_fixed_without_pos   s    MM!]]:-PQQQqc* R &!V$]]:-PQQQq!f#6 R qAC8sB6BsssB6BBBBB RQ
 RQs   D	D!D	!D1	c                h  a ^ RI o\        P                  ! 4       pVP                  . RO4       ^ R/p^ .p\        P                  ! WVR7      p\
        ;QJ d-    V3R lVP                  4        4       F  '       g   K   RM"	  RM! V3R lVP                  4        4       4      pV'       d   Q R4       hR# )	r'   Nr   r   c              3   V   <"   T F  q F  pSP                  V4      x  K  	  K   	  R # 5ir   )isnan)r   coordscmaths   &  r   r"   2TestLayout.test_spring_init_pos.<locals>.<genexpr>,   s#     O,1djjmmm,s   &)TFzvalues should not be nan))r'   r%   r%   r)   )r)   r'   )r)              r?   )r:   r	   r   add_edges_fromfruchterman_reingold_layoutanyvalues)r0   r1   init_pos	fixed_posr   has_nanr:   s   &     @r   test_spring_init_posTestLayout.test_spring_init_pos"   s~    HHJ	9:z?C	,,QIN#O#**,O###O#**,OO666{7r   c                   . p\         P                  ! V4       \         P                  ! V4       \         P                  ! V4       \         P                  ! V4       \         P
                  ! V4       \         P                  ! V4       \         P                  ! V4       \         P                  ! W4       \         P                  ! V4       \         P                  ! V4       \         P                  ! V4       R # r   )r	   random_layoutcircular_layoutplanar_layoutr.   rA   spectral_layoutshell_layoutbipartite_layoutspiral_layoutmultipartite_layoutkamada_kawai_layoutr0   r1   s   & r   test_smoke_empty_graph!TestLayout.test_smoke_empty_graph/   s    

1


&&q)
1

A!

q!
q!r   c                   V P                   p\        P                  ! V4       \        P                  ! V4       \        P                  ! V4       \        P
                  ! V4       \        P                  ! V4       \        P                  ! V4       \        P                  ! V P                  4       \        P                  ! V4       \        P                  ! VP                  4       4       \        P                  ! V P                  4       \        P                  ! V P                  P                  4       4       \        P                  ! V4       \        P                  ! V4       \        P                  ! V4       \        P                  ! V^R7       \        P                  ! V^R7       \        P                  ! V4       R# r%   dimN)r   r	   rJ   rK   rL   r.   forceatlas2_layoutrA   r   rM   to_directedrN   rP   rR   
arf_layoutrS   s   & r   test_smoke_intTestLayout.test_smoke_int=   s   GG

1


a 
&&q)
&&tyy1
1
1==?+
499%
4990023


q!
qa(
qa(
ar   c                b   V P                   p\        P                  ! V4       \        P                  ! V4       \        P                  ! V4       \        P
                  ! V4       \        P                  ! V4       \        P                  ! V4       \        P                  ! V4       \        P                  ! V4       \        P                  ! V4       \        P                  ! V4       \        P                  ! V^R7       \        P                  ! V^R7       \        P                  ! V4       R# rW   )r   r	   rJ   rK   rL   r.   rZ   rA   rM   rN   rP   rR   r\   rS   s   & r   test_smoke_stringTestLayout.test_smoke_stringQ   s    GG

1


a 
&&q)
1


q!
qa(
qa(
ar   c                   \         P                  V4      pW2,
          pW2,           p\         P                  \        VP                  4       4      4      pVP	                  ^ 4      VP                  ^ 4      ,
          pV^V,          8*  P                  4       '       g   Q hWd8  P                  4       '       g   Q hWe8*  P                  4       '       g   Q hR# r'   N)r   arraylistrC   maxminr/   )r0   r   scalecenterlowhivposlengths   &&&&    r   check_scale_and_center!TestLayout.check_scale_and_centera   s    &!n^xxSZZ\*+!txx{*!e)#((****  """"
!!!!r   c           	        V P                   pRp\        P                  ! ^	4      pVP                  ^	4       V! \        P                  ! W2R7      RRR7       V! \        P
                  ! V^VR7      ^VR7       V! \        P                  ! V^VR7      ^VR7       V! \        P                  ! V^VR7      ^VR7       V! \        P                  ! V^VR7      ^VR7       V! \        P                  ! V^VR7      ^VR7       V! \        P                  ! V^VR7      ^VR7       RpV! \        P                  ! V^^VR7      ^VR7       R# )	r   ri         ?rh   ri   )rY   rh   ri   N)r   r   )g      @g      @)r)   r=   r   rn   r	   complete_graphadd_noderJ   r.   rM   rK   rN   rP   rR   r0   scr9   r1   s   &   r   test_scale_and_center_arg$TestLayout.test_scale_and_center_argk   s   ((a 	

1
2A(JG
2AQq11E
2aq31QG
2aq31QG
2??1Aa0!D
2AQq11E
2!!!1Q7qK
2!!!!A>aPQRr   c                    \         P                  ! ^	4      p\        P                  ! \         P                  \         P
                  V4       R# )	   N)r	   ru   r+   r,   NetworkXExceptionrL   rS   s   & r   #test_planar_layout_non_planar_input.TestLayout.test_planar_layout_non_planar_input|   s.    a b**B,<,<a@r   c           	         \         P                  ! 4       pVP                  ^ ^^.^^ ^.^^ ^./4       \         P                  ! V4       R# rc   )r	   PlanarEmbeddingset_datarL   )r0   	embeddings   & r   (test_smoke_planar_layout_embedding_input3TestLayout.test_smoke_planar_layout_embedding_input   sE    &&(	A1vq1a&!aV<=
#r   c                h   V P                   pRp\        P                  ! ^	4      pVP                  ^	4       V! \        P                  ! V4      RRR7       V! \        P
                  ! V4      ^VR7       V! \        P                  ! V4      ^VR7       V! \        P                  ! V4      ^VR7       V! \        P                  ! V4      ^VR7       V! \        P                  ! V4      ^VR7       V! \        P                  ! V4      ^VR7       RpV! \        P                  ! V^R7      ^VR7       R# )r'   rr   rs   rX   Nr&   rr   rr   )r'   r'   r'   rt   rw   s   &   r   test_default_scale_and_center(TestLayout.test_default_scale_and_center   s    ((a 	

1
2Ac*=
2Aa2
2a !4
2a !4
2??1Qq1
2Aa2
2!!!$Aa8
2!!!+1Q?r   c                   \         P                  ! ^4      p\        P                  ! \        \         P
                  V^R7       \        P                  ! \        \         P                  V^R7       \        P                  ! \        \         P                  V^R7       \        P                  ! \        \         P                  V^R7       \        P                  ! \        \         P                  V^R7       R# )r   rX   N)r	   r*   r+   r,   r-   rK   rN   rL   rS   s   & r   (test_circular_planar_and_shell_dim_error3TestLayout.test_circular_planar_and_shell_dim_error   s    MM!j""4"4aQ?j"//1!<j"//1!<j""2"2A1=j""2"2A1=r   c                   \         P                  ! V P                  4      p\         P                  P                  P                  V4      pVP                  R8X  g   Q h\         P                  P                  P                  V^R7      pVP                  R8X  g   Q h\         P                  P                  P                  V4      pVP                  R8X  g   Q hR# )   rX   Nr   r)   r   r=   )r	   to_numpy_arrayr   drawinglayout_fruchterman_reingoldshape_sparse_fruchterman_reingoldr0   Ar   s   &  r   test_adjacency_interface_numpy)TestLayout.test_adjacency_interface_numpy   s    dgg&jj55a8yyF"""jj55aQ5?yyF"""jj<<Q?yyF"""r   c                   \         P                  ! V P                  R R7      p\         P                  P                  P                  V4      pVP                  R8X  g   Q h\         P                  P                  P                  V4      pVP                  R8X  g   Q h\         P                  P                  P                  V^R7      pVP                  R8X  g   Q hR# )d)dtyperX   Nr   r   )r	   to_scipy_sparse_arrayr   r   r   r   r   _sparse_spectralr   s   &  r   test_adjacency_interface_scipy)TestLayout.test_adjacency_interface_scipy   s    $$TWWC8jj<<Q?yyF"""jj003yyF"""jj<<QA<FyyF"""r   c                t   \         P                  ! ^4      p\         P                  ! V4      pV^ ,          P                  4       '       d   Q h\         P                  ! ^4      p\         P                  ! V^ .^^.^..4      pV^ ,          P                  4       '       d   Q hV^,          P                  4       '       g   Q h\        P
                  P                  V^,          4      ^8:  g   Q h\         P                  ! V^ .^^.^..^ R7      p\        P
                  P                  V^,          4      ^8:  g   Q hR# )r%   )rotateN)r	   r*   rN   rB   r   linalgnormr0   r1   rl   s   &  r   test_single_nodesTestLayout.test_single_nodes   s    MM!q!7;;==  MM!qA3A"457;;==  Aw{{}}}yy~~d1g&!+++qA3A"4Q?yy~~d1g&!+++r   c                    \         P                  ! V P                  4      p\         P                  ! V P                  VR 7      pR# r   N)r	   rK   r   rZ   r0   r   nposs   &  r   "test_smoke_initial_pos_forceatlas2-TestLayout.test_smoke_initial_pos_forceatlas2   s,      )$$TWW#6r   c                    \         P                  ! V P                  4      p\         P                  ! V P                  VR 7      pR# r   )r	   rK   r   rA   r   s   &  r   +test_smoke_initial_pos_fruchterman_reingold6TestLayout.test_smoke_initial_pos_fruchterman_reingold   s,      )--dgg3?r   c                    \         P                  ! V P                  4      p\         P                  ! V P                  VR 7      pR# r   )r	   rK   r   r\   r   s   &  r   test_smoke_initial_pos_arf%TestLayout.test_smoke_initial_pos_arf   s*      )}}TWW#.r   c                   \         P                  ! V P                  4      p\         P                  ! V P                  VR.R7      p\	        VR,          4      \	        VR,          4      8X  g   Q h\         P                  ! V P
                  4      p\         P                  ! V P
                  VR.R7      p\        ^4       F>  pVR,          V,          \        P                  ! VR,          V,          RR7      8X  d   K>  Q h	  R# )r'   r5   Hz>absNr&   )	r	   rK   r   r.   tupler   ranger+   approx)r0   r   r   axiss   &   r   $test_fixed_node_fruchterman_reingold/TestLayout.test_fixed_node_fruchterman_reingold   s      )SAS[!U4<%8888  +		s6(C!HDv;t$d6l46Hd(SSSS r   c                   \         P                  ! ^4      p\         P                  ! VRR7       \         P                  ! VRR7      p\	        V^ ,          4      R8X  g   Q h\         P
                  ! VRR7      p\	        V^ ,          4      R8X  g   Q h\         P                  ! VRR7      p\	        V^ ,          4      R8X  g   Q h\         P                  ! VRR7      p\	        V^ ,          4      R8X  g   Q h\         P                  ! VRR7      p\	        V^ ,          4      R8X  g   Q h\         P                  ! VRR7      p\	        V^ ,          4      R8X  g   Q h\         P                  ! VRR7      p\	        V^ ,          4      R8X  g   Q hR# r%   rq   Nr$   )r	   r*   rJ   rK   r   rL   r.   rA   rM   rN   rP   r   s   &  r   test_center_parameter TestLayout.test_center_parameter   s6   MM!
6*!!!F3T!W~'''&1T!W~'''&1T!W~'''--a?T!W~'''!!!F3T!W~'''q0T!W~'''&1T!W~'''r   c                   \         P                  ! ^4      p\        \         P                  4      \        \         P                  4      8X  g   Q h\
        P                  ! \        \         P                  VRR7       \
        P                  ! \        \         P                  VRR7       \
        P                  ! \        \         P                  VRR7       \
        P                  ! \        \         P                  VRR7       \
        P                  ! \        \         P                  V^RR7       \
        P                  ! \        \         P                  VRR7       \
        P                  ! \        \         P                  V^RR7       \
        P                  ! \        \         P                  VRR7       \
        P                  ! \        \         P                  VRR7       \
        P                  ! \        \         P                  VRR7       R# )r%   rq   )rY   ri   N)r%   r%   r%   r$   )r	   r*   idr.   rA   r+   r,   r-   rJ   rK   rL   rM   rN   rP   rR   rS   s   & r   test_center_wrong_dimensions'TestLayout.test_center_wrong_dimensions   s&   MM!"""#r"*H*H'IIIIj""2"2AiHj""4"4a	Jj""2"2AiHj""2"2AiHj""2"2A1VLj""4"4a	Jj""4"4aQvNj"//1YGj""2"2AiHj""8"8!INr   c                ~   \         P                  ! 4       p\         P                  ! VRR7      pV/ 8X  g   Q h\         P                  ! VRR7      pV/ 8X  g   Q h\         P                  ! VRR7      pV/ 8X  g   Q h\         P
                  ! W4      pV/ 8X  g   Q h\         P                  ! VRR7      pV/ 8X  g   Q h\         P                  ! VRR7      pV/ 8X  g   Q h\         P                  ! VRR7      pV/ 8X  g   Q h\         P                  ! VRR7      pV/ 8X  g   Q h\         P                  ! VRR7      pV/ 8X  g   Q h\         P                  ! VRR7      pV/ 8X  g   Q h\         P                  ! VRR7      pV/ 8X  g   Q h\         P                  ! V4      pV/ 8X  g   Q h\         P                  ! V4      pV/ 8X  g   Q hR# r   )r	   empty_graphrJ   rK   rL   rO   r.   rA   rM   rN   rP   rQ   rR   rZ   r\   r   s   &  r   test_empty_graphTestLayout.test_empty_graph   s   NN&1rzz!!!F3rzz&1rzz""1(rzz&1rzz--a?rzz!!!F3rzzq0rzz&1rzz%%a7rzz%%a7rzz$$Q'rzz}}Qrzzr   c           	        \         P                  ! ^^4      p\         P                  P                  V4      w  r#\         P                  ! W4      p\        V4      \        V4      8X  g   Q hV\        V4      ^ ,          ,          ^ ,          pV\        V4      ^ ,          ,          ^ ,          pV F  pWG,          ^ ,          V8X  d   K  Q h	  V F  pWG,          ^ ,          V8X  d   K  Q h	  \         P                  ! WRR^^R7      p\        V4      \        V4      8X  g   Q hV\        V4      ^ ,          ,          ^,          pV\        V4      ^ ,          ,          ^,          p	V F  pWG,          ^,          V8X  d   K  Q h	  V F  pWG,          ^,          V	8X  d   K  Q h	  \        P                  ! \        \         P                  WRR7       R# )r=   
horizontal)alignri   rh   aspect_ratiofoor   Nr)   r)   )
r	   complete_bipartite_graph	bipartitesetsrO   lenre   r+   r,   r-   )
r0   r1   topbottomrl   top_xbottom_xnodetop_ybottom_ys
   &         r   test_bipartite_layout TestLayout.test_bipartite_layout  ss   ''1-ll''*""1*4yCF"""T#Yq\"1%VQ(+D:a=E))) D:a=H,,,  "",vQQ
 4yCF"""T#Yq\"1%VQ(+D:a=E))) D:a=H,,,  	j""5"5qUKr   c                f  aa R
p\         P                  ! V!  p\         P                  ! V4      o\        S4      \        V4      8X  g   Q h^ oV F{  pSV,           p\        ;QJ d1    VV3R l\        S^,           V4       4       F  '       d   K   RM&	  RM"! VV3R l\        S^,           V4       4       4      '       g   Q hSV,          oK}  	  \         P                  ! VR^RR7      o\        S4      \        V4      8X  g   Q h^ oV F{  pSV,           p\        ;QJ d1    VV3R l\        S^,           V4       4       F  '       d   K   RM&	  RM"! VV3R l\        S^,           V4       4       4      '       g   Q hSV,          oK}  	  \        P                  ! \        \         P                  VRR7       R	# )r'   c              3   f   <"   T F&  pSS,          ^ ,          SV,          ^ ,          8H  x  K(  	  R# 5irc    r   istartrl   s   & r   r"   6TestLayout.test_multipartite_layout.<locals>.<genexpr>5  (     S=RtE{1~a3=R   .1FTr   )r   rh   ri   c              3   f   <"   T F&  pSS,          ^,          SV,          ^,          8H  x  K(  	  R# 5i)r%   Nr   r   s   & r   r"   r   >  r   r   r   r   N)r'   r      r)      r   )	r	   complete_multipartite_graphrQ   r   r/   r   r+   r,   r-   )r0   sizesr1   r    endr   rl   s   &    @@r   test_multipartite_layout#TestLayout.test_multipartite_layout+  sB   **E2%%a(4yCF"""A!)C3SU519c=RS333SU519c=RSSSSSQJE 
 %%a|1VT4yCF"""A!)C3SU519c=RS333SU519c=RSSSSSQJE 
 	j""8"8!5Ir   c                   \         P                  P                  P                  p\        P                  R R.4      p^\        P                  RR.RR..4      ,          pV! V\        V^ ^R7      w  rEV\        P                  ! R
RR7      8X  g   Q hV^ ,          \        P                  ! RRR7      8X  g   Q hV^,          \        P                  ! RRR7      8X  g   Q hR	# )g      @g      @皙?g       @333333?
meanweightrY   r   r   rr   Ng      ?      )r	   r   r   _kamada_kawai_costfnr   rd   r+   r   )r0   costfnr   invdistcostgrads   &     r   test_kamada_kawai_costfn_1d&TestLayout.test_kamada_kawai_costfn_1dC  s    ""77hhSz"bhhc
S#J788CWB
v}}&8tDDDDAw&--D9999Aw&--6666r   c           
        \         P                  P                  P                  pV! VP	                  4       \
        W#VR 7      w  rgRV,          \
        P                  \
        P                  V^ R7      ^,          4      ,          p\        VP                  ^ ,          4       F  p	\        V	^,           VP                  ^ ,          4       F_  p
\
        P                  P                  W,          W,          ,
          4      pWW),          V
,          ,          R,
          ^,          ,          pKa  	  K  	  V\        P                  ! VRR7      8X  g   Q hRp\        VP                  ^ ,          4       EF  p\        VP                  ^,          4       F  pWP                  ^,          ,          V,           pVP                  4       pVV;;,          V,          uu&   V! V\
        W#VP                  ^,          R 7      ^ ,          pVV;;,          ^V,          ,          uu&   V! V\
        W#VP                  ^,          R 7      ^ ,          pW,          \        P                  ! VV,
          ^V,          ,          RR7      8X  d   K  Q h	  EK  	  R# )	r   rr   r         ?r   r   g-C6?h㈵>N)r	   r   r   r   ravelr   sumr   r   r   r   r+   r   flatten)r0   r   r   meanwtrY   r   r   r   expected_costr   jdiffdxnddmidxpscpluscminuss   &&&&&              r   check_kamada_kawai_costfn$TestLayout.check_kamada_kawai_costfnO  s   ""77CIIKWSQ
frvvbffSqf.AQ.F'GGsyy|$A1q5#))A,/yy~~cfsvo6A"6"<!BB 0 %
 v}}]====		!%BCIIaL)99Q<'",[[]32r2wsyyQR|TUVW31r6!B		RSUVWXyFMM56>a"f2MSW$XXXX * &r   c                   ^\         P                  . RO. RO. R	O.4      ,          pRp\         P                  RR
.RR.RR..4      pV P                  W1V^4       \         P                  . RO. RO. RO.4      pV P                  W1V^4       R# )r%   r   g?g@gffffff@g      @N)r    @333333?)r  g?333333?)r  r  r   g	g333333ӿ)g?g333333!@gffffff!)ir   gffffff)g333333"@g333333 g?)r   rd   r  )r0   r   r  r   s   &   r   test_kamada_kawai_costfn#TestLayout.test_kamada_kawai_costfnj  s    bhh/RSS hhdc4[3*=>&&sVQ? hh(*;=MNO&&sVQ?r   c           	     h   V P                   p\        P                  \        \        P
                  ! VR R7      P                  4       4      4      p\        P                  \        \        P
                  ! VRR7      P                  4       4      4      p\        P                  P                  VRR
 VR,          ,
          ^R7      p\        P                  P                  VRR
 VR,          ,
          ^R7      p\        V4      \        V4      8  g   Q h\        P                  \        \        P
                  ! VRR7      P                  4       4      4      p\        P                  P                  VRR
 VR,          ,
          ^R7      p\        P                  VR,          VR
,          RR	7      '       g   Q hR# )gffffff?)
resolutiong(\?Nr%   NNr   T)equidistantg{Gz?atol)r   r   rd   re   r	   rP   rC   r   r   r  allclose)r0   r1   pos_standardpos_tighter	distancesdistances_tighterpos_equidistantdistances_equidistants   &       r   test_spiral_layoutTestLayout.test_spiral_layoutx  sS   GG xxR%5%5aD%I%P%P%R SThhtB$4$4Q4$H$O$O$QRSIINN<#4|B7G#GaNP	IINN;s+;k"o+MTUNV9~$5 6666 ((4(8(8(M(T(T(V#WX "		CR ?2#66Q !/ !
 {{!"%'<R'@t  
 
 	
 
r   c                   \         P                  ! ^
4      p\         P                  ! VRRR7       \         P                  ! VR4      p\        P                  \        VP                  4       4      4      p\        P                  P                  VR,          VRR	 ,
          ^R7      p\        P                  \        P                  V4      ^ RR7      '       g   Q hR# )

   Tr   )r  store_pos_asr  Nr   gMbP?r  r  )r	   r*   rP   get_node_attributesr   rd   re   rC   r   r   r  r  )r0   r1   r   pdists   &    r   test_spiral_layout_equidistant)TestLayout.test_spiral_layout_equidistant  s    MM"
5A$$Q.HHT#**,'(yy~~aeafn1~5{{2774=!${7777r   c                    V P                   p\        P                  P                  V4      p\        P                  ! V4      pW2 \        P
                  ! WR 7      p\        V4      \        V4      8X  g   Q hR# r   )r   r	   utilsarbitrary_elementrK   rZ   r   r0   r1   r   r   s   &   r   *test_forceatlas2_layout_partial_input_test5TestLayout.test_forceatlas2_layout_partial_input_test  sZ    GGxx))!,  #I##A/3x3q6!!!r   c                4   \         P                  ! 4       p\         P                  ! VRR7      p\         P                  ! V4      / 8X  g   Q h\         P                  ! ^4      p^ R^R/p\         P                  ! V4      p\        P
                  P                  \        VP                  4       !   Uu. uF  p\        V4      NK  	  up4      R8  g   Q h\         P                  ! ^4      p^ R^R^R	/p\         P                  ! V4      p^ \        P                  R
4      ^\        P                  R4      ^\        P                  R4      /pVP                  4        F&  w  rgW6,          V8H  P                  4       '       d   K&  Q h	  \         P                  ! V^R7      p^ \        P                  R4      ^\        P                  R4      ^\        P                  R4      /pVP                  4        F&  w  rgW6,          V8H  P                  4       '       d   K&  Q h	  R# u upi )r%   rq   gư>)rh   Nr$   r>   )r   r   r&   r   )r  r  )r7  r   )r	   r   rJ   rescale_layout_dictr   r   r   ziprC   r  rd   itemsr/   )r0   r1   rl   s_vposxexpectationkvs   &       r   test_rescale_layout_dict#TestLayout.test_rescale_layout_dict  s   NN&1%%d+r111NN1:q*-''-yy~~sFMMO/DE/D!s1v/DEFMMMNN161fa4''- rxx!rxxrxx

  %%'DAIN'')))) (''A6rxx!rxxrxx

  %%'DAIN'')))) (' Fs   /Hc                    V P                   p\        P                  P                  V4      p\        P                  ! V4      pW2 \        P
                  ! WR 7      p\        V4      \        V4      8X  g   Q hR# r   )r   r	   r1  r2  rK   r\   r   r3  s   &   r   "test_arf_layout_partial_input_test-TestLayout.test_arf_layout_partial_input_test  sX    GGxx))!,  #ImmA'3x3q6!!!r   c                v    V P                   p\        P                  ! \        \        P
                  VRR7       R# )z\
Checks input parameters correctly raises errors. For example,  `a` should be larger than 1
)r1   aNr  )r   r+   r,   r-   r	   r\   rS   s   & r    test_arf_layout_negative_a_check+TestLayout.test_arf_layout_negative_a_check  s#     GGj"--1;r   c                    V P                   p\        P                  ! V^*R7       \        P                  ! V^*R7       \        P                  ! V^*R7       \        P
                  ! V^*R7       R# )*   )seedN)r   r	   rJ   r.   r\   rZ   rS   s   & r   test_smoke_seed_input TestLayout.test_smoke_seed_input  sI    GG
$
$
ab!
ab)r   c                    \         P                  ! ^4      p\        ^4       Uu/ uF  q"V^,
          R.bK  	  pp\         P                  ! WR7      pR# u upi )r=   r?   r   Nr	   r*   r   rZ   r0   r1   r   orig_posnew_poss   &    r   test_node_at_centerTestLayout.test_node_at_center  sG    MM!-21X6XAs|OX6''8 7s   Ac                    \         P                  ! ^4      p\        ^4       Uu/ uF  q"V^,
          R.bK  	  pp\         P                  ! W^*R7      pR# u upi )r=   r?   )r   rK  NrO  rP  s   &    r   test_initial_only_some_pos%TestLayout.test_initial_only_some_pos  sI    MM!-21X6XAs|OX6''bA 7s   Ar   N)+__name__
__module____qualname____firstlineno__classmethodr   r2   rG   rT   r]   r`   rn   ry   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r&  r.  r4  r@  rC  rG  rL  rS  rV  __static_attributes____classdictcell__)__classdict__s   @r   r   r      s     , ,C7"( "S"A$
@ >##
,7@/	T($O:L8J0
7Y6@
,8"*<"<*9B Br   r   c                 P   \         P                  ! 4       p V P                  ^ RR7       V P                  ^RR7       V P                  ^RR7       V P                  ^RR7       V P                  . RO4       \         P                  ! V 4      p\        V4      \        V 4      8X  g   Q hR# )zSee gh-5123.s0subsets1N)r(   )r'   r=   r<   )r	   r   rv   r@   rQ   r   r1   r   s     r   4test_multipartite_layout_nonnumeric_partition_labelsrf    s    

AJJqJJJqJJJqJJJqJ-.

 
 
#Cs8s1vr   c                    \         P                  ! 4       p \        \        RR4      4      pVP	                  4        F  w  r#V P                  W#R7       K  	  \         P                  ! V RR7      p\         P                  P                  V4      p\         P                  ! V RVR	7      p\        VP	                  4       VP	                  4       4       F*  w  w  rxw  rWy8X  d   W8H  P                  4       '       d   K*  Q h	  VR,          R,          VR,          R,          8X  g   Q hVR,          R,          VR,          R,          u;8  d-   VR,          R,          u;8  d   VR,          R,          8  g   Q h Q hR
V P                  R,          R&   \         P                  ! V 4      pVP                  4       VP                  4       8X  g   Q hR# )zcReturn the layers in sorted order if the layers of the multipartite
graph are sortable. See gh-5691rF  br9   r   erb  r   r   )r   
subset_keylayer_0rc  N)rF  rh  r9   r   ri  )r)   r=   r%   r)   r   r  )r	   r   dictr9  r:  rv   rQ   r1  groupsr/   nodeskeys)r1   
node_groupr   layerr   layerspos_from_layersn1p1n2p2
pos_nosorts               r   $test_multipartite_layout_layer_orderry    s^    	
Ac3_EFJ!'')	

4
& * 
 
 ,
7CXX__Z(F,,QlvVO!#))+/D/D/FG(2xRXNN,,,, H s8B<3s8B<'''s8B<#c(2,DS"DCDDDDD 'AGGCL''*J??
***r   c                    \         P                  \        V P                  4       4      4      R,          p\         P	                  VRR7      w  r#V# )zJHelper function to extract the number of nodes in each layer of bfs_layoutT)return_counts):NNNr'   )r   rd   re   rC   unique)r   r<  _layer_counts   &   r   _num_nodes_per_bfs_layerr  	  s:    
cjjl#$T*AYYqY5NAr   r    c                    \         P                  ! V 4      p\         P                  ! V^ RR7       \         P                  ! VR4      p\        P                  \        V4      ^V ^,
          .4      '       g   Q hR# )znThe complete graph should result in two layers: the starting node and
a second layer containing all neighbors.r   )r   r*  N)r	   ru   
bfs_layoutr+  r   r   r  )r    r1   r   s   &  r   test_bfs_layout_complete_graphr    s[     	!AMM!151

 
 E
*C>>237!QUDDDDr   c                     \         P                  ! ^^4      p \         P                  ! V ^ R7      p. ROp\        P	                  \        V4      V4      '       g   Q h\         P                  ! V ^R7      p\        P	                  \        V4      V4      '       g   Q h\         P                  ! V ^R7      p. ROp\        P	                  \        V4      V4      '       g   Q hR# )r   r   N)r%   r   r%   r%   r%   r%   r   )r%   r)   r)   r   )r	   barbell_graphr  r   r   r  )r1   r   expected_nodes_per_layers      r   test_bfs_layout_barbellr    s    
AA
--
#C4>>2379QRRRR
--
$C>>2379QRRRR
--
#C+>>2379QRRRRr   c                     \         P                  ! ^4      p V P                  RR.4       \        P                  ! \         P
                  RR7      ;_uu_ 4        \         P                  ! V ^ R7       RRR4       R#   + '       g   i     R# ; i)r   z#bfs_layout didn't include all nodesr   r  N)r)     )r     )r	   ru   r@   r+   r,   NetworkXErrorr  )r1   s    r   test_bfs_layout_disconnectedr  +  s[    
!Ah)*	r''/T	U	U
aq! 
V	U	U	Us   A;;B	c                  &   \         P                  ! ^4      p \        P                  ! \         P                  RR7      ;_uu_ 4        \         P
                  ! V 4       RRR4       \         P
                  ! V ^^.R7      pR#   + '       g   i     L,; i)r   zGraph is not bipartiter   N)rn  )r	   ru   r+   r,   r  rO   re  s     r   >test_bipartite_layout_default_nodes_raises_non_bipartite_inputr  2  s`    
!A	r''/G	H	H
A 
I 

a1v
.C 
I	Hs   B  B	c                  z  a \         P                  ! ^^4      p \         P                  ! V 4      p\         P                  P	                  V 4       Fd  pV Uu. uF  q1V,          ^ ,          NK  	  upo\
        ;QJ d    V3R lS 4       F  '       d   K   RM	  RM! V3R lS 4       4      '       d   Kd  Q h	  R# u upi )r=   c              3   b   <"   T F$  q\         P                  ! S^ ,          4      8H  x  K&  	  R# 5irc   )r+   r   )r   r<  xss   & r   r"   6test_bipartite_layout_default_nodes.<locals>.<genexpr>@  s!     9bbe,,bs   ,/FTN)r	   r   rO   r   r   r/   )r1   r   nodesetr>  r  s       @r   #test_bipartite_layout_default_nodesr  :  s    
##Aq)A


a
 C<<$$Q'!()A!fQii)s9b9sss9b99999 ()s   B8r   c                    \         P                  ! ^4      pRP                  . RO4      p\        P                  ! \
        VR7      ;_uu_ 4        V ! VRR7       RRR4       R#   + '       g   i     R# ; i)z>Test all layouts that support dim kwarg handle invalid inputs.|r   rX   N)z negative dimensions.*not allowedzcan only handle 2zcannot handle.*2r  )r	   r*   joinr+   r,   r-   )r   r1   valid_err_msgss   &  r   test_layouts_negative_dimr  C  sQ      	aAXX	
N 
z	8	8qb 
9	8	8	8s   A##A4	extra_layout_kwargsr   r   rY   c                >   \         P                  ! V 4      pRp\         P                  ! V3RVRV/VB p\         P                  ! V3RRRV/VB p\        P	                  \        VP                  4       4      \        VP                  4       4      RR7      '       g   Q hR# )z;Expect 'force' layout for n < 500 and 'energy' for n >= 500ix	methodrK  autor  r  N)r	   cycle_graphr.   r   r  re   rC   )	num_nodesexpected_methodr  r1   rK  expectedactuals   &&&    r   'test_spring_layout_graph_size_heuristicr  _  s     	y!AD 	!(,0CH aQQTQ=PQF;;tHOO-.V]]_0ED;QQQQr   )r  r  )d   force)i  energyr&   )__doc__r+   networkxr	   importorskipr   r   rf  ry  r  markparametrizer   r  r  r  r  r  rJ   rK   rN   r.   rR   rM   rL   rP   rZ   r  r  r   r   r   <module>r     sr   &  !   G TB TBn	+6 eAqk*E +ES""/: 









 $~&G 
	FWqc*	
RRr   