+
    ,iH                        ^ RI Ht ^ RIt^ RIt^ RIHtHtHt ^ RI	H
t ^ RIHtHtHtHtHtHtHt ^ RIt^ RIHt ^ RI	t	^ RIt]P2                  ! . R3O. R4O. R5O. R6O. R7O.]R7      t]P2                  ! . R8O. R9O. R:O. R;O. R<O.]R7      t]^ 8  P;                  ]4      t. R=O. R>O]P>                  ]P>                  ^ ]P>                  ]P>                  .. R?O. R@O.t . RAO. RBO.t!]P2                  ! . R8O. R>O. RCO. RDO. REO.]R7      t"]P2                  ! ^ ]P>                  ]P>                  ^^.]P>                  ^ ]P>                  ^]P>                  .]P>                  ]P>                  ^ ]P>                  ]P>                  .^^]P>                  ^ ^.^]P>                  ]P>                  ^^ ..]R7      t#]PH                  ! RF]R7      ]PJ                  ! ^4      ,
          t&]P>                  ]&]&^ 8  &   ]P2                  ! . RGO. RHO. RIO. RJO. RKO.]R7      t']P2                  ! . RLO. RMO. RNO. ROO. RPO.]R7      t(]PR                  PU                  . RQO. RRO. RSO33RFR7      t+^ ^ ^]P>                  ]P>                  .^^ ^]P>                  ]P>                  .^^^ ]P>                  ]P>                  .]P>                  ]P>                  ]P>                  ^ ^.]P>                  ]P>                  ]P>                  ^^ ..t,]PR                  PU                  . RTO. RUO. RVO33RFR7      t-^ ^ ^]P>                  ]P>                  .^ ^ ^]P>                  ]P>                  .^^^ ]P>                  ]P>                  .]P>                  ]P>                  ]P>                  ^ ^.]P>                  ]P>                  ]P>                  ^^ ..t.]P2                  ! . RWO. RYO. RZO.]R7      t/]P2                  ! ^ ]P>                  ]P>                  .RX^ ]P>                  .. R[O.]R7      t0. R\Ot1R	 t2R
 t3R t4R t5R t6]	Pn                  Pq                  RR] 3R]"334      ]	Pn                  Pq                  R. R]O^ ^.^^.^ ^ .34      R 4       4       t9]	Pn                  Pq                  RR^4      R 4       t:]	Pn                  Pq                  RR_4      ]	Pn                  Pq                  R. R`O4      ]	Pn                  Pq                  RRa4      R 4       4       4       t;R t<R t=R t>R t?R t@]	Pn                  Pq                  RRR.4      R 4       tAR tBR tC]	Pn                  Pq                  R. R`O4      R  4       tDR! tER" tF]	Pn                  Pq                  R]14      R# 4       tG]	Pn                  P                  ]P                  ! 4       P                  R$4      R%R&7      R' 4       tKR( tLR) tMR* tNR+ tOR, tPR- tQR. tR]	Pn                  Pq                  R/Ra4      ]	Pn                  Pq                  RRa4      ]	Pn                  Pq                  R0Ra4      ]	Pn                  Pq                  R1]P                  ]P                  34      ]	Pn                  Pq                  RR^.34      R2 4       4       4       4       4       tUR# )b    )StringION)assert_array_almost_equalassert_array_equalassert_allclose)raises)shortest_pathdijkstrajohnsonbellman_fordconstruct_dist_matrixyenNegativeCycleError)mmreaddtypeshapec                      ^ ^\         P                  .p \        \        \        .pR p\        W4       F  w  r4V! W44       K  	  R# )r   c                 @    \        \        R V R7      p\        W!4       R# )F)directedlimitN)r	   undirected_Gr   )r   resultSPs   && O/usr/lib/python3/dist-packages/scipy/sparse/csgraph/tests/test_shortest_path.pycheck"test_dijkstra_limit.<locals>.checkq   s    lU%@!"-    N)npinfundirected_SP_limit_0undirected_SP_limit_2undirected_SPzip)limitsresultsr   r   r   s        r   test_dijkstra_limitr'   k   sA    BFF^F$$G. V-e .r   c                  6    R  p \          F  pV ! V4       K  	  R# )c                 L    \        \        V R RR7      p\        V\        4       R# TFmethodr   	overwriteNr   
directed_Gr   directed_SPr,   r   s   & r   r   test_directed.<locals>.checkz       :ft%*,!"k2r   Nmethodsr   r,   s     r   test_directedr7   y   s    3
 f r   c                  H    R  p \          F  pR F  pV ! W4       K  	  K  	  R# )c                     V'       d&   \        \        V R R R7      p\        V\        4       R# \        \        V RR R7      p\        V\        4       R# Fr+   TN)r   r/   r   r#   r   r,   directed_inSP1SP2s   &&  r   r   test_undirected.<locals>.check   s?    
6E*/1C%c=9Vd*/1C%c=9r   NTFr4   r   r,   r<   s      r   test_undirectedrB      s%    : (K&& ) r   c                  6    R  p \          F  pV ! V4       K  	  R# )c                 L    \        \        V R RR7      p\        V\        4       R# r*   )r   directed_sparse_zero_Gr   directed_sparse_zero_SPr1   s   & r   r   (test_directed_sparse_zero.<locals>.check   s!    1&4%*,!"&=>r   Nr4   r6   s     r   test_directed_sparse_zerorH      s    ?
 f r   c                  H    R  p \          F  pR F  pV ! W4       K  	  K  	  R# )c                     V'       d&   \        \        V R R R7      p\        V\        4       R# \        \        V RR R7      p\        V\        4       R# r:   )r   rE   r   undirected_sparse_zero_SPundirected_sparse_zero_Gr;   s   &&  r   r   *test_undirected_sparse_zero.<locals>.check   sE     6vPU*/1C%c+DE 8RV*/1C%c+DEr   Nr@   r4   rA   s      r   test_undirected_sparse_zerorN      s&    F (K&& ) r   zdirected, SP_ansTFindicesc                 f   \         P                  ! V4      p\         P                  ! V\         P                  R 7      pV\         P                  ! WR3,          ^ R7      ,          p\         P                  ! VP
                  ^ ,          VP                  4      p\        VP
                  ^ ,          4       F  pWV,          V3,          WE&   K  	  RV\         P                  ! V4      &   \        \        V VRRR7      w  rgp\        Wd4       \        W84       \        \        V VRRR7      p\        Wd4       R# )r   NNN)axisTr   rO   min_onlyreturn_predecessorsFN)r   arrayint64argminzerosr   r   rangeisinfr	   r/   r   r   )	r   SP_ansrO   min_ind_ans	min_d_anskr   predsourcess	   &&&      r   test_dijkstra_indices_min_onlyrc      s    
 XXfFhhwbhh/G"))FA:$6Q?@Ka&,,7I6<<?#!na/0	 $',K#$ *2)0*.59	;Bg
 b,{,	*#!&+	
-B
 b,r   nc                 6   \         P                  P                  R 4      p\        P                  P                  W 3RRV\         P                  R7      pVP                  \         P                  ! V \         P                  R7      4       \         P                  ! V 4      pVP                  V4       VR\        V R,          4       p\        VRVRRR7      w  rVp\        V 4       F3  pWh,          p	Wx,          p
V	R	8w  g   K  Wy,          V
8X  g   Q hWi,          p	K"  	  R# )
l   	X/ g      ?lil)densityformatrngr   r   Ng?TrS   rV   )r   randomdefault_rngscipysparserandom_arrayfloat64setdiagrZ   bool_arangeshuffleintr	   r[   )rd   ri   datavrO   dsra   rb   r`   pss   &          r   test_dijkstra_min_only_randomrz      s    
))

 3
4C<<$$aVS),BJJ % @DLL!288,-
		!AKKN
QrTmG *.)0*.59	;Bg
 1XGJ5j:?"?A r   r,   r   c                    \         P                  ! W 3\        R 7      p^ p\        V 4      ;W4R3&   VRV3&   \        P
                  P                  W0V 3R7      p\         P                  ! W 3\        R 7      pW4,          VR&   \        ^V 4       F  pWg;;,          W7V3,          ,          uu&   K!  	  \         P                  ! V^ 4       \        WQVR7      p\        Wh4       R# )r   rQ   r   )r,   r   N)
r   rZ   floatr[   rl   rm   
csr_matrixfill_diagonalr   r   )	rd   r,   r   star_arrstar_center_idxGSP_solutionidxr   s	   &&&      r   test_star_graphr      s    
 xxe,HOBG(JHa 8A,>#?A7A((A6/K.KNQ{H/%9:: [!$	q(	;Br   c                      ^
p . ROp. ROp. ROp\         P                  P                  W1V3W 3R7      p\        VRRR7       R# )
   r   Tr   rU   N)r      r         	   r            r   r      r   r   r   r   r   )r   r   r   r   r   r               r   )g2}ƅ?gMg'?gx@e?gN]?ghn?g16T?g|\?g%e?gh o?g-?gn\?g$~?g<,Ԛ?ga?ge1?g{?gbE?g?)rl   rm   	csr_arrayr	   )rd   rO   indptrru   graphs        r   test_dijkstra_randomr      sF    
ADG2F0D LL""D6#:1&"IEUTt<r   c                  R    R p \        \        V 4      RR7      p\        VRRR7       R# )a  %%MatrixMarket matrix coordinate real general
                84 84 22
                2 1 4.699999809265137e+00
                6 14 1.199999973177910e-01
                9 6 1.199999973177910e-01
                10 16 2.012000083923340e+01
                11 10 1.422000026702881e+01
                12 1 9.645999908447266e+01
                13 18 2.012000083923340e+01
                14 13 4.679999828338623e+00
                15 11 1.199999973177910e-01
                16 12 1.199999973177910e-01
                18 15 1.199999973177910e-01
                32 2 2.299999952316284e+00
                33 20 6.000000000000000e+00
                33 32 5.000000000000000e+00
                36 9 3.720000028610229e+00
                36 37 3.720000028610229e+00
                36 38 3.720000028610229e+00
                37 44 8.159999847412109e+00
                38 32 7.903999328613281e+01
                43 20 2.400000000000000e+01
                43 33 4.000000000000000e+00
                44 43 6.028000259399414e+01
    F)spmatrixTr   N)r   r   r	   )textru   s     r   test_gh_17782_segfaultr     s'    D2 (4.51DTDd;r   c                     a \         P                  ! ^4      oV3R lp R F(  p\        \        \        \
        3 F  pV ! W!4       K  	  K*  	  \        \        \
        \        RSR7       R# )r   c                    < VR,           pV ! \         RSP                  V4      R7      p\        V\        S,          P                  V4      4       R# )r   F)r   rO   N)r   )r/   reshaper   r#   )funcindshapeoutshaper   rO   s   &&  r   r   )test_shortest_path_indices.<locals>.check$  s@    d?*u!//(35!"mG&<&D&DX&NOr   FW)r,   rO   N))r   )r   r   )r   r   )	r   rr   r	   r   r
   r   assert_raises
ValueErrorr/   )r   r   r   rO   s      @r   test_shortest_path_indicesr   !  sS    iilGP +|WmDD$! E + *mZ!#r   c                     aa R \         R\        /oR \        R\        /oVV3R lp \         F  pR F  pV ! W4       K  	  K  	  R# )TFc                 ~   < \        \        WR RR7      w  r#\        VSV,          4       \        VSV,          4       R# FTr   r-   rU   N)r   r/   r   )r,   r   r   ra   SP_respred_ress   &&  r   r    test_predecessors.<locals>.check8  s9     V+059; 	""fX&67!$(:;r   Nr@   )r0   r#   directed_predundirected_predr5   )r   r,   r   r   r   s      @@r   test_predecessorsr   2  sH    K]$Fm(H< %H&# & r   c                  H    R  p \          F  pR F  pV ! W4       K  	  K  	  R# )c                 h    \        \        VR RR7      w  r#\        \        W1R7      p\        W$4       R# )FTr   r   N)r   r/   r   r   )r,   r   r=   ra   r>   s   &&   r   r   +test_construct_shortest_path.<locals>.checkE  s/    !*+3,16:<	 $JH!#+r   Nr@   r4   r   r,   r   s      r   test_construct_shortest_pathr   D  s%    , %H&# & r   c                     \        \        V R RR7      w  r\        \        \        \        VP                  \        P                  4      V 4       R# r   )r   r/   r   	TypeErrorr   astyper   rX   )r   r=   ra   s   &  r   -test_construct_dist_matrix_predecessors_errorr   Q  s<    j)1*/48:IC )2dkk"((3X?r   c                  H    R  p \          F  pR F  pV ! W4       K  	  K  	  R# )c                 h    \        \        VR RR7      p\        \        VR R R7      p\        W#4       R# )FT)r   r-   
unweightedN)r   r/   unweighted_Gr   )r,   r   r=   r>   s   &&  r   r   #test_unweighted_path.<locals>.check\  s8    J%-&+'+- L%-&+',. 	"#+r   Nr@   r4   r   s      r   test_unweighted_pathr   [  s%    	, %H&# & r   c                     a \         P                  ! ^^.4      o^ SP                  R&   RSR&   V3R lp R F.  pR F  pV ! W!4       K  	  \        \        \
        S^ ^^VR7       K0  	  R# )	r   :NNr   c                 6   < \        \        \        SV V4       R # )N)r   r   r   )r,   r   r   s   &&r   r   #test_negative_cycles.<locals>.checkr  s    (-	 r   r   N)r   r   r@   r   JBF)r   onesflatr   r   r   )r   r   r,   r   s      @r   test_negative_cyclesr   l  sg    GGQFOEEJJsOE$K  "'F&# ( 	(#uaA'	)	 "r   c                 N    \        \        V R R7      p\        V\        RR7       R# )Tr   g|=)atolN)r   directed_negative_weighted_Gr   directed_negative_weighted_SPr1   s   & r   test_negative_weightsr   ~  s    	3Vd	KBB5EBr   c                  ~    \         P                  P                  \        ^ 4       R p \         F  pV ! V4       K  	  R# )r   c                 L    \        \        V R RR7      p\        V\        4       R# r*   r.   r1   s   & r   r    test_masked_input.<locals>.check  r3   r   N)r   mamasked_equalr/   r5   r6   s     r   test_masked_inputr     s.    EEz1%3
 f r   c                      \         P                  ! . RO. RO. RO. RO. R	O.\        R7      p V P                  4       p\	        VRR7       \        W4       R# )
r   r   F)r-   Nr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   rW   r|   copyr   r   )r   foos     r   test_overwriter     sG    
/!!!!	# +0		1A
 &&(C#'sr   c                     \         P                  P                  R ..4      pRVP                  P                  R&   \        WR7       R# )      ?F	WRITEABLE)r,   N)rl   rm   r   ru   flagsr   )r,   r   s   & r   test_bufferr     s6     	v&A %AFFLL!#r   mips64ztest known to fail on mips64el)reasonc            	          \         P                  ! R R7      ;_uu_ 4       p \        \        P                  ! ^ ^.\        P
                  ^ ..4      4       RRR4       X  F  pVP                  \        Jd   K  Q h	  R#   + '       g   i     L1; i)T)recordN)warningscatch_warningsr   r   rW   nancategoryRuntimeWarning)r   rs     r   test_NaN_warningsr     sa    		 	 	-	-bhhA456 
.zz///  
.	-s   4A==B	c                     \         P                  ! . RO. RO. RO. RO. RO.\        R7      p \        V 4      p\        P
                  P                  V 4      p\        P
                  P                  V 4      p\        P
                  P                  V 4      p\        V\        V4      4       \        V\        V4      4       \        V\        V4      4       R# )r   r   N)r   r   r   r   r   )r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   )
r   rW   r|   r   rl   rm   r   	csc_array	lil_arrayr   )G_denser   G_csrG_cscG_lils        r   test_sparse_matricesr     s    hh('''	) 16	7G
 
w	BLL""7+ELL""7+ELL""7+Eb-"67b-"67b-"67r   c                  n    \        \        ^ ^^RR7      w  r\        V RR.4       \        V\        4       R# )r   T)sourcesinkKrU         @      "@Nr   r/   r   directed_2SP_0_to_3	distancespredecessorss     r   test_yen_directedr    s9    !&#$!"04I IBx(L"56r   c                      \         P                  ! . RO. RO. RO. RO. R	O.\        R7      p \        V ^ ^^RR7      p\	        V. R
O4       R# )r   r   Fr   r   r   r   Nr   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )       @      @       @r   g      &@)r   rW   r|   r   r   )dense_undirected_Gr  s     r   test_yen_denser    sR    &&&&&#(
 056 "I I45r   c                  J    \        \        ^ ^^RR7      p \        V . RO4       R# )r   Fr  N)r   g      @r   r	  )r   r   r   r  s    r   test_yen_undirectedr    s(    
I I/0r   c            	      p    \        \        ^ ^^RRR7      w  r\        V RR.4       \        V\        4       R# )r   T)r   r   r   r   rU   r  r  Nr   r  s     r   test_yen_unweightedr    s<    !
 I IBx(L"56r   c                  R    \        \        ^^^R7      p V P                  ^ 8X  g   Q hR# )r   r   r   r   N)r   r/   sizer  s    r   test_yen_no_pathsr    s,    
	I >>Qr   c                  F    \        \        ^^ ^R7      p \        V R.4       R# )r   r  Ng       )r   r   r   r  s    r   test_yen_negative_weightsr    s&    $
	I Iu%r   rT   rU   index_dtypec                $   \         P                  P                  ^RR7      p\         P                  P                  VP                  VP
                  P                  V4      VP                  P                  V4      34      p\        VVVV VR7       R# )z;Test two failures from gh-20904: int32 and indices-as-None.csr)rh   )rO   rT   rU   N)	rl   rm   	eye_arrayr   ru   rO   r   r   r	   )rT   r   rU   r  rO   adj_mats   &&&&& r   
test_20904r  	  sz     ll$$Qu$5Gll$$LLOO"";/NN!!+.	
G /r   )r   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )rV   r   rV   r   rV   )rV   r   rV   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   )rV   r   r   r   r   )r   rV   r   r   r   )rV   rV   rV   rV   rV   )r   r   r   rV   r   )r   r   r   r   rV   )rV   r   r   r   r   )r   rV   r   r   r   )r   r   rV   r   r   )r   r   r   rV   r   )r   r   r   r   rV   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   )r   r   r   )r   r   r   )r   r   r   )autor   Dr   r   )r   r   r   )r   d   i  )r   r  r   r@   )Vior   r   numpyr   numpy.testingr   r   r   pytestr   r   scipy.sparse.csgraphr   r	   r
   r   r   r   r   scipy.sparserl   scipy.ior   platformrW   r|   r/   r   r   r   r    r0   r   r#   r"   r   eyer!   r   r   rm   r   rE   rF   rL   rK   r   r   r5   r'   r7   rB   rH   rN   markparametrizerc   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   skipifmachine
startswithr   r   r  r  r  r  r  r  int32rX   r   r   r   <module>r0     s      X X *6 6 6    XX&&&&	( 05	6
 xx((((	* 27	8 Q&&u- 2662662	  3.0  /))))	+ 38	9 1bffbffa";#%661bffa"@#%662661bffbff"E#$aA"6#$bffbffa";	"= EJ	K  e4rvvay@ 3566 +a/ 0 --=--	/ 7<	= ((/////	1 9>	? //	/*  0   q!RVVRVV4!Q/!Q/vvrvvrvvq!4vvrvvrvvq!4	6  !<<11 	!#;<  2    Arvvrvv6Aq"&&"&&1Aq"&&"&&1A6A6	8   "xx)3)3)5<A C  !#1bffbff*=+-q"&&/*5*7>C!E  )' '  +- -023 YAAA$GH- I3-0 o. /, i(#45]3 4 6 )&	=<<#"$$$ dE]3? 4?$")$ #45C 6C
	 7+$ ,$ H$$&11(;Dde0 f08 	76"17& ]3]3.>288(<=TA3K0 1 > ? 4 4
r   