
    Gd#                         d dl Z  e j        d          Z e j        d           d dlZd dlmZ d dlmZ d Z	 G d d          Z
dS )	    Nnumpyscipy)NetworkXError)havel_hakimi_graphc                  "   g d} t          |           }g d} t          j        | d          }t          j        |                                                              t                    }t                              g dg dg dg dg d	g          }t          j	        
                    ||           t          j        |                                                              t                    }t                              g d
g d
g dg dg dg dg dg dg          }t          j	        
                    ||           t          j        t                    5  t          j        |ddg           d d d            d S # 1 swxY w Y   d S )N      r
      r   )r   r   r   r   )r
   r   r   )r
   r   r   r   r   *   )seed)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   nodelist)r   nxrandom_clustered_graphincidence_matrixtodenseastypeintnparraytestingassert_equalpytestraisesr   )degGMGIexpecteds        Flib/python3.11/site-packages/networkx/linalg/tests/test_graphmatrix.pytest_incidence_matrix_simpler'      s   
//C3A
J
J
JC		"3R	0	0	0B
A&&((//44Axx							 H JAx(((
B''))0055Axx																									 	 	H JAx(((	}	%	% 0 0
AA////0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0s   FFFc                   6    e Zd Zed             Zd Zd Zd ZdS )TestGraphMatrixc                    g d}t          |          | _        t                              g dg dg dg dg dg          | _        t                              g dg dg d	g d
g dg          | _        t          |          | _        | j                            d | j                                        D                        t                              g dg dg dg dg dg          | _	        t          j        | j                  | _        | j                                        | _        | j                            dd           t                              g dg dg d	g d
g dg          | _        t                              g dg dg dg dg dg          | _        t          j        dddddifg          | _        t                              ddgddgg          | _        d S )Nr   )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   c              3   ,   K   | ]\  }}||d ddfV  dS )      ?333333?weightotherN ).0uvs      r&   	<genexpr>z.TestGraphMatrix.setup_class.<locals>.<genexpr>F   sF       
 
6<q!QcC001
 
 
 
 
 
    )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
   r0      )r   r"   r   r   OIAWGadd_edges_fromedgesWAr   
MultiGraphr#   copyMG2add_edgeMG2AMGOIGraph
no_edges_G
no_edges_A)clsr!   s     r&   setup_classzTestGraphMatrix.setup_class1   s3   oo"3''__]]\\\\\\	
 
 __________	
 
 $C(( 
 
@C
 
 
 	
 	
 	
 """      __	
 
 su%%&++--A88__________	
 
 88   ______	
 
 6Aq8Q-+@"ABBAq6Aq6"233r7   c                 .   t          j        | j        t          | j                  t          | j                                                  d                                                              t                    }t          j	        
                    || j                   t          j        | j        t          | j                  t          | j                                                  d                                                              t                    }t          j	        
                    |t                              | j                             t          j        | j        t          | j                  t          | j                                                  d                                                              t                    }t          j	        
                    || j                   t          j        | j        t          | j                  t          | j                                                  d                                                              t                    }t          j	        
                    |t                              | j                             t          j        | j        t          | j                  t          | j                                                  d                                                              t                    }t          j	        
                    || j                   t          j        | j        t          | j                  t          | j                                                  d                                                              t                    }t          j	        
                    |t                              | j                             dS )zConversion to incidence matrixTr   edgelistorientedFN)r   r   r"   sortedr=   r   r   r   r   r   r   r9   absr#   rA   rD   )selfr$   s     r&   test_incidence_matrixz%TestGraphMatrix.test_incidence_matrixh   s    //	   WYYVC[[ 	
 	
47+++ //	   WYYVC[[ 	
 	
266$'??333 00	   WYYVC[[ 	
 	
47+++ 00	   WYYVC[[ 	
 	
266$'??333 )) 0 011	   WYYVC[[ 	
 	
49---  0 011	   WYYVC[[ 	
 	
266$)#4#455555r7   c           	      	   t          j        | j        t          | j                  t          | j                                                  d                                                              t                    }t          j	        
                    || j                   t          j        | j        t          | j                  t          | j                                                  d                                                              t                    }t          j	        
                    |t                              | j                             t          j        | j        t          | j                  t          | j                                                  dd                                          }t          j	        
                    |d| j        z             t          j        | j        t          | j                  t          | j                                                  dd                                          }t          j	        
                    |t                              d| j        z                       t          j        | j        t          | j                  t          | j                                                  dd                                          }t          j	        
                    |d| j        z             t          j        | j                  }|                    d	d
dd           t          j        |t          |          t          |                    d                    dd                                          }t          j	        
                    |d| j        z             t          j        |t          |          t          |                    d                    dd                                          }t          j	        
                    |t                              d| j        z                       t          j        |t          |          t          |                    d                    dd                                          }t          j	        
                    |d| j        z             d S )NTrK   Fr0   )r   rL   rM   r0   r-   r1   r.   r   r   r/   )keys)r   r   r;   rN   r=   r   r   r   r   r   r   r9   rO   r?   rB   rD   )rP   r$   WMGs      r&   test_weighted_incidence_matrixz.TestGraphMatrix.test_weighted_incidence_matrix   s   00	   WYYVC[[ 	
 	
47+++ 00	   WYYVC[[ 	
 	
266$'??333 GDG__DGMMOO,,
 
 
 ')) 	
 	
3=111GDG__DGMMOO,,
 
 
 ')) 	
 	
266#-#8#8999GDG__DGMMOO,,
 
 
 ')) 	
 	
3=111 mDG$$Q#S111C[[CII4I0011
 
 
 ')) 	
 	
3?333C[[CII4I0011
 
 
 ')) 	
 	
266#	/#:#:;;;C[[CII4I0011
 
 
 ')) 	
 	
3?33333r7   c                    t           j                            t          j        | j                                                  | j                   t           j                            t          j        | j                                                  | j                   t           j                            t          j        | j	                                                  | j
                   t           j                            t          j        | j        ddg                                          | j        ddddf                    t           j                            t          j        | j                                                  | j                   t           j                            t          j        | j        d                                          | j                   t           j                            t          j        | j	        d                                          | j
                   t           j                            t          j        | j        d                                          d| j        z             t           j                            t          j        | j        dd	g                                          | j                   dS )
zConversion to adjacency matrixr   r   r   Nr
   )r0   r1   g333333?r	   )r   r   r   r   adjacency_matrixr"   r   r:   r#   rA   rC   r;   r>   rF   rG   )rP   s    r&   test_adjacency_matrixz%TestGraphMatrix.test_adjacency_matrix  s9   

 3DF ; ; C C E EtvNNN

 3DG < < D D F FOOO

 3DH = = E E G GSSS

!Q888@@BBDF2A2rPQr6N	
 	
 	
 	
 3DG < < D D F FPPP

555==??	
 	
 	
 	
666>>@@$)	
 	
 	
 	
888@@BBC$'M	
 	
 	
 	
1a&AAAIIKKO	
 	
 	
 	
 	
r7   N)__name__
__module____qualname__classmethodrI   rQ   rU   rX   r2   r7   r&   r)   r)   0   sc        44 44 [44lH6 H6 H6T`4 `4 `4D
 
 
 
 
r7   r)   )r   importorskipr   networkxr   networkx.exceptionr   networkx.generators.degree_seqr   r'   r)   r2   r7   r&   <module>ra      s    V!!  G        , , , , , , = = = = = ="0 "0 "0Jy
 y
 y
 y
 y
 y
 y
 y
 y
 y
r7   