
    sh6                     |    S SK r S SKr\ R                  " S5      r\ R                  " S5         " S S5      rS rS rg)    Nnumpyscipyc                   0    \ rS rSr\S 5       rS rS rSrg)TestLaplacian	   c                    / SQn[         R                  " U5      U l        [         R                  " S U R                  R	                  5        5       5      U l        U R
                  R                  S5        [         R                  " U R                  5      U l        U R                  R                  5       U l
        U R                  R                  5        H  nU R                  R                  X"5        M      [         R                  " 5       U l        U R                  R                  S5        [         R                   " U R                  5      U l        [         R                  " S U R                  R	                  5        5       5      U l        U R                  R                  5       U l        U R&                  R                  5        H  nU R&                  R                  X"5        M      g )N)      r
      r   c              3   4   #    U  H  u  pXS SS.4v   M     g7f      ?333333?)weightotherN .0uvs      x/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/networkx/linalg/tests/test_laplacian.py	<genexpr>,TestLaplacian.setup_class.<locals>.<genexpr>   s      
@MfqQcC01      
r   r
   r   r	   )r	   r   )r	   r
   )r	      )r   r   )r      )r   r   )r   r    )r    r   c              3   4   #    U  H  u  pXS SS.4v   M     g7fr   r   r   s      r   r   r   +   s      
@OfqQcC01r   )nxhavel_hakimi_graphGGraphedgesWGadd_node
MultiGraphMGcopyGslnodesadd_edgeDiGraphDiGadd_edges_fromMultiDiGraphDiMGDiWGDiGsl)clsdegnodes      r   setup_classTestLaplacian.setup_class
   s<   %%c* 
@C
 
 	suu% %%**,GGMMODGGT( $
 **,	
 ??377+:: 
@C
 
 GGLLN	IIOO%DIIt* &    c           	      B   [         R                  / SQ/ SQ/ SQ/ SQ/ SQ/5      nSU-  nSU-  n[         R                  / SQ/ S	Q/ S
Q/ SQ/ SQ/ SQ/5      nSU-  nSU-  n[         R                  R                  [        R
                  " U R                  5      R                  5       U5        [         R                  R                  [        R
                  " U R                  5      R                  5       U5        [         R                  R                  [        R
                  " U R                  SS/S9R                  5       [         R                  SS/SS//5      5        [         R                  R                  [        R
                  " U R                  5      R                  5       U5        [         R                  R                  [        R
                  " U R                  SS9R                  5       U5        [         R                  R                  [        R
                  " U R                  SS9R                  5       U5        [         R                  R                  [        R
                  " U R                  5      R                  5       U5        [         R                  R                  [        R
                  " U R                  5      R                  5       U5        [         R                  R                  [        R
                  " U R                  SS/S9R                  5       [         R                  SS/SS//5      5        [         R                  R                  [        R
                  " U R                  5      R                  5       U5        [         R                  R                  [        R
                  " U R                  SS9R                  5       U5        [         R                  R                  [        R
                  " U R                  SS9R                  5       U5        g)zGraph Laplacian)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   r   r=   r
   r=   )r   r   r   r   r=   r   r   r   nodelistr=   Nr   r   r
   )nparraytestingassert_equalr"   laplacian_matrixr$   todenser*   r'   r0   r3   r4   )selfNLWLOLDiNLDiWLDiOLs          r   test_laplacianTestLaplacian.test_laplacian2   s    XX+++++	- . 2X2Xxx1111113 4 TzTz


 3 3DFF ; C C ErJ


 3 3DGG < D D FK


!Q8@@BHHq"gAw'(	
 	

 3 3DGG < D D FK


 3 3DGGD I Q Q SUWX


8@@BB	
 	

 3 3DHH = E E GN


 3 3DII > F F H$O


Aq6:BBDHHq"g1v&'	
 	

 3 3DII > F F H$O


		$7??A4	
 	

		':BBDd	
r;   c           	         [         R                  / SQ/ SQ/ SQ/ SQ/ SQ/5      n[         R                  / SQ/ SQ/ SQ/ SQ/ SQ/5      n[         R                  / SQ/ SQ/ SQ/ S	Q/ SQ/5      n[         R                  / S
Q/ SQ/ SQ/ SQ/ SQ/ SQ/5      n[         R                  / S
Q/ SQ/ SQ/ SQ/ SQ/ SQ/5      n[         R                  / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n[         R                  R                  [        R
                  " U R                  [        S5      S9R                  5       USS9  [         R                  R                  [        R
                  " U R                  5      R                  5       USS9  [         R                  R                  [        R
                  " U R                  5      R                  5       USS9  [         R                  R                  [        R
                  " U R                  5      R                  5       USS9  [         R                  R                  [        R
                  " U R                  SS9R                  5       USS9  [         R                  R                  [        R
                  " U R                  5      R                  5       USS9  [         R                  R                  [        R
                  " U R                  [        SS5      S9R                  5       USS9  [         R                  R                  [        R
                  " U R                  5      R                  5       USS9  [         R                  R                  [        R
                  " U R                  5      R                  5       USS9  [         R                  R                  [        R
                  " U R                  5      R                  5       USS9  [         R                  R                  [        R
                  " U R                  SS9R                  5       USS9  [         R                  R                  [        R
                  " U R                  5      R                  5       USS9  g) zGeneralized Graph Laplacian)      ?&1ڿrR   X9v        )rR   rQ         rT   rT   )rR   rU   rQ   rT   rT   )rS   rT   rT   rQ   rT   )rT   rT   rT   rT   rT   )      ?登zҿrW   eaֿrT   )rW   K=U?ioTտrT   rT   )rW   rZ   rY   rT   rT   )rX   rT   rT   r   rT   )rQ   rT   rڿrT   rT   rT   )rT   rT   rT   rT   rT   rT   )r[   rT   rQ   rT   r[   rT   )rT   rT   rT   rQ   rU   -)rT   rT   rT   rU   rQ   r\   )rT   rT   rT   r\   rT   rQ   )r[   rT   rQ   r[   rT   rT   )rT   rT   rT   rT   r\   rQ   )rY   gzrW   rT   rT   rT   )rW   rU   rV   rW   rT   rT   )rT   rT   rT   rY   rZ   r[   )rT   rT   rT   rZ   rY   r[   )rT   rT   rT   rT   r[   r   r   r>   r	   decimalr   r@   r      N)rA   rB   rC   assert_almost_equalr"   normalized_laplacian_matrixr$   rangerF   r*   r'   r,   r0   r3   r4   r5   )rG   r$   GLLslr0   DiGLDiLsls          r   test_normalized_laplacian'TestLaplacian.test_normalized_laplaciana   s    HH;;;;;	= >
 XX?????	A B
 hhEEEEE	G H hhNNNNNNP Q xxOOOOOOQ R PPPPPPR S 	

&&**466E!HEMMO 	' 	

 	

&&**4662::<b! 	' 	
 	

&&**4773;;=r1 	' 	
 	

&&**4773;;=r1 	' 	
 	

&&**4777CKKM 	' 	

 	

&&**4884<<>Q 	' 	
 	

&&**q% gi 	' 	
 	

&&**4884<<>a 	' 	
 	

&&**4995==?q 	' 	
 	

&&**4995==?q 	' 	
 	

&&**499WEMMO 	' 	

 	

&&**4::6>>@%QR 	' 	
r;   r   N)	__name__
__module____qualname____firstlineno__classmethodr9   rN   rg   __static_attributes__r   r;   r   r   r   	   s!    %+ %+N-
^V
r;   r   c            	         [         R                  " 5       n U R                  S5        [        R	                  / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n[         R
                  " U S[        U 5      S	9n[        R                  R                  X!S
S9  U R                  S5        [        R	                  / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n[         R
                  " U S[        U 5      SS9n[        R                  R                  X!S
S9  [        R	                  / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n[         R
                  " U S[        U 5      SS9n[        R                  R                  X!S
S9  [         R                  " 5       n U R                  S5        [        R	                  / SQ/ SQ/ SQ/ S Q/5      n[         R
                  " U S[        U 5      S	9n[        R                  R                  X!S
S9  g!)"zDirected Laplacianr   )ŏ1w?:pΈҿ*Dؿ\ Ac̝着&}гY)rq   g7d?8gDioͿS!uqGx$(篔ec])rr   rv   rp   PkwǺݵ|г)rs   rw   rz   rp   H}8߿\(\)rt   rx   r{   r}   rp   )0ʿ)ru   ry   r|   r~   r   rp   ?alphar?   r	   r]   )r
   r   )r    r   )rQ   @ǘӿfj+޿rT   rT   ,ԚԿ)r   rQ   	h"lx¿rT   [<ԿrT   )r   r   rQ   rT   o_rT   )rT   rT   rT   rQ   rU   rU   )rT   r   r   rU   rQ         п)r   rT   rT   rU   r   rQ   randomr   r?   	walk_type)r   @ǘÿfj+οrT   rT   TĿ)r   r   ]m{rT   [<ĿrT   )r   r   r   rT   +eXrT   )rT   rT   rT   r   r   r   )rT   r   r   r   r         )r   rT   rT   r   r   r   lazy)r   )r
   r   )r   r   r   )r	   r   )r   I+ƿr   r   )r   r   rT   r   )r   rT   r   r   )r   r   r   r   N)	r"   r/   r1   rA   rB   directed_laplacian_matrixsortedrC   r`   )r$   rc   Ls      r   test_directed_laplacianr      s   
 	

A	
 
IIIIIIK 
LB 	$$QcF1IFAJJ""1!"4 %&	IIIIIIK 
LB 	$$	vayH	A JJ""1!"4 
IIIIIIK 
LB 	$$QcF1IQWXAJJ""1!"4 	

A=>	33335 
6B
 	$$QcF1IFAJJ""1!"4r;   c            	         [         R                  " 5       n U R                  S5        [        R	                  / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n[         R
                  " U S[        U 5      S	9n[        R                  R                  X!S
S9  U R                  S5        [        R	                  / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n[         R
                  " U S[        U 5      SS9n[        R                  R                  X!S
S9  [        R	                  / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n[         R
                  " U S[        U 5      SS9n[        R                  R                  X!S
S9  [         R                  " [         R                  " S5      5      n[         R
                  " U5      n[        R	                  / SQ/ SQ/ SQ/ S Q/5      n[        R                  R                  X$S!S9  [        R                  " [         R                  5         [         R
                  " U S"S#S$9  S%S%S%5        [        R                  " [         R                  5         [         R
                  " U S&S'9  S%S%S%5        g%! , (       d  f       NQ= f! , (       d  f       g%= f)(z Directed combinatorial Laplacianr   )g46<?F%uK=U_QkMb`_vOf)r   g
ףp=
?Aǘŏ1w-!a+eylxz,C|)r   r   gZӼ?y&1lSt$r   )r   r   r   g|Pk?z6>W[<Nё\˿)r   r   r   r   gt?B`"۩)r   r   r   r   r   gjt?r   r   r	   r]   r   )gB`"?Biޡ+ΧrT   rT   :H)r   g+η?rT   r   rT   )r   r   Biޱ?rT   r   rT   )rT   rT   rT   KY8?KY8Žr   )rT   r   r   r   r   r   )r   rT   rT   r   r   r   r   r   )r   5;Nё$ۗrT   rT   rs   )r   g+Χ?wrT   r   rT   )r   r   gBiޡ?rT   r   rT   )rT   rT   rT   KY8Ž?r   r   )rT   r   r   r   r   rs   )rs   rT   rT   r   rs   r   r   r
   )K}\UU?iKGUUr   rT   )r   r   rT   r   )r   rT   r   r   )rT   r   r   r   r    pagerankd   )r   r   Nsilly)r   )r"   r/   r1   rA   rB   'directed_combinatorial_laplacian_matrixr   rC   r`   margulis_gabber_galil_graphpytestraisesNetworkXError)r$   rc   r   Eexpecteds        r   %test_directed_combinatorial_laplacianr      s   
 	

A	
 
IIIIIIK 
LB 	221C&QR)TAJJ""1!"4 %& 
IIIIIIK 
LB 	22	vayH	A JJ""1!"4 
IIIIIIK 
LB 	22	vayF	A JJ""1!"4


211!45A
2215Axx	=	=	=	=	?H JJ""1":	r''	(
221
RUV 
)	r''	(
221H 
)	( 
)	(	(	(s   	I+I<+
I9<
J
)r   networkxr"   importorskiprA   r   r   r   r   r;   r   <module>r      sD     !   G n
 n
bC5LNIr;   