
    \Mh!                         d dl Z d dlZd dlmZ  e j        d          Z e j        d           d Z G d d          ZdS )    N)NetworkXErrornumpyscipyc                     g d} t          j        |           }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dtype)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)nxhavel_hakimi_graphrandom_clustered_graphincidence_matrixinttodensenparraytestingassert_equalpytestraisesr   )degGMGIexpecteds        f/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/networkx/linalg/tests/test_graphmatrix.pytest_incidence_matrix_simpler(   
   s   
//C
c""A
J
J
JC		"3R	0	0	0B
AS)))1133Axx							 H JAx(((
Bc***2244A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   E''E+.E+c                   6    e Zd Zed             Zd Zd Zd ZdS )TestGraphMatrixc                    g d}t          j        |          | _        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        |          | _        | 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>E   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	   r1      )r   r   r#   r   r   OIAWGadd_edges_fromedgesWA
MultiGraphr$   copyMG2add_edgeMG2AMGOIGraph
no_edges_G
no_edges_A)clsr"   s     r'   setup_classzTestGraphMatrix.setup_class0   s9   oo%c**__]]\\\\\\	
 
 __________	
 
 &s++ 
 
@C
 
 
 	
 	
 	
 """      __	
 
 su%%&++--A88__________	
 
 88   ______	
 
 6Aq8Q-+@"ABBAq6Aq6"233r8   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                             t          j        | j        t          j                  }|j        t          j        k    sJ dS )zConversion to incidence matrixTr   edgelistorientedr   Fr   N)r   r   r#   sortedr>   r   r   r   r   r   r:   absr$   rB   rE   uint8r   )selfr%   s     r'   test_incidence_matrixz%TestGraphMatrix.test_incidence_matrixg   s   FDF^^DFLLNN++
 
 
 ')) 	
 	
47+++FDF^^DFLLNN++
 
 
 ')) 	
 	
266$'??333GDG__DGMMOO,,
 
 
 ')) 	
 	
47+++GDG__DGMMOO,,
 
 
 ')) 	
 	
266$'??333HDH%%DHNN,,--
 
 
 ')) 	
 	
49---HDG__DHNN,,--
 
 
 ')) 	
 	
266$)#4#4555bh777w"(""""""r8   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 )NTrL   Fr1   )r   rM   rN   r1   r.   r2   r/   r   r
   r0   )keys)r   r   r<   rO   r>   r   r   r   r   r   r:   rP   r@   rC   rE   )rR   r%   WMGs      r'   test_weighted_incidence_matrixz.TestGraphMatrix.test_weighted_incidence_matrix   s   GDG__DGMMOO,,
 
 
 ')) 	
 	
47+++GDG__DGMMOO,,
 
 
 ')) 	
 	
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3r8   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	   )r1   r2   g333333?r   )r   r   r   r   adjacency_matrixr#   r   r;   r$   rB   rD   r<   r?   rG   rH   )rR   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	
 	
 	
 	
 	
r8   N)__name__
__module____qualname__classmethodrJ   rS   rW   rZ   r3   r8   r'   r*   r*   /   s`        44 44 [44l9# 9# 9#vZ4 Z4 Z4x
 
 
 
 
r8   r*   )	r    networkxr   networkx.exceptionr   importorskipr   r(   r*   r3   r8   r'   <module>rb      s         , , , , , ,V!!  G   "0 "0 "0Jd
 d
 d
 d
 d
 d
 d
 d
 d
 d
r8   