a
    º”h"  ã                   @   sV   d dl Z e  d¡Ze  d¡ d dlZd dlmZ d dlmZ dd„ Z	G dd	„ d	ƒZ
dS )
é    NÚnumpyZscipy)ÚNetworkXError)Úhavel_hakimi_graphc                  C   s  g d¢} t | ƒ}g d¢} tj| dd}tj|td ¡ }t g d¢g d¢g d¢g d	¢g d
¢g¡}tj 	||¡ tj|td ¡ }t g d¢g d¢g d¢g d¢g d¢g d¢g d¢g d¢g¡}tj 	||¡ t
 t¡" tj|ddgd W d   ƒ n1 sú0    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)r   ÚnxZrandom_clustered_graphÚincidence_matrixÚintÚtodenseÚnpÚarrayÚtestingÚassert_equalÚpytestZraisesr   )ÚdegÚGÚMGÚIÚexpected© r"   úT/var/www/auris/lib/python3.9/site-packages/networkx/linalg/tests/test_graphmatrix.pyÚtest_incidence_matrix_simple   s:    üÿùÿr$   c                   @   s0   e Zd Zedd„ ƒZdd„ Zdd„ Zdd„ Zd	S )
ÚTestGraphMatrixc                 C   sh  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d„ | j ¡ D ƒ¡ t g d¢g d¢g d¢g d¢g d¢g¡| _	t
 | 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
 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                 s   s"   | ]\}}||d ddœfV  qdS )ç      à?ç333333Ó?©ÚweightÚotherNr"   )Ú.0ÚuÚvr"   r"   r#   Ú	<genexpr>F   s   z.TestGraphMatrix.setup_class.<locals>.<genexpr>)r   r'   r'   r'   r   )r'   r   r'   r   r   )r'   r'   r   r   r   )r'   r   r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r&   r&   r&   r&   r   )r   r   r   r   r&   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r*   é   )r   r   r   r   ÚOIÚAÚWGZadd_edges_fromÚedgesÚWAr   Ú
MultiGraphr   ÚcopyÚMG2Úadd_edgeÚMG2AÚMGOIZGraphÚ
no_edges_GÚ
no_edges_A)Úclsr   r"   r"   r#   Úsetup_class1   sf    
üÿüÿ
ÿüÿüÿüÿzTestGraphMatrix.setup_classc                 C   s–  t j| jt| jƒt| j ¡ ƒdtd ¡ }tj 	|| j
¡ t j| jt| jƒt| j ¡ ƒdtd ¡ }tj 	|t | j
¡¡ t j| jt| jƒt| j ¡ ƒdtd ¡ }tj 	|| j
¡ t j| jt| jƒt| j ¡ ƒdtd ¡ }tj 	|t | j
¡¡ t j| jt| jƒt| j ¡ ƒdtd ¡ }tj 	|| j¡ t j| jt| jƒt| j ¡ ƒdtd ¡ }tj 	|t | j¡¡ t j| jtjd}|jtjks’J ‚dS )zConversion to incidence matrixT©r   ÚedgelistÚorientedr   Fr   N)r   r   r   Úsortedr4   r   r   r   r   r   r1   Úabsr   r8   r;   Zuint8r   )Úselfr    r"   r"   r#   Útest_incidence_matrixh   sd    û
û
û
û
û
û
z%TestGraphMatrix.test_incidence_matrixc                 C   s  t j| jt| jƒt| j ¡ ƒdtd ¡ }tj 	|| j
¡ t j| jt| jƒt| j ¡ ƒdtd ¡ }tj 	|t | j
¡¡ t j| jt| jƒt| j ¡ ƒddd ¡ }tj 	|d| j
 ¡ t j| jt| jƒt| j ¡ ƒddd ¡ }tj 	|t d| j
 ¡¡ t j| jt| jƒt| j ¡ ƒddd ¡ }tj 	|d| j
 ¡ t  | j¡}|jd	d
ddd t j|t|ƒt|jddƒddd ¡ }tj 	|d| j ¡ t j|t|ƒt|jddƒddd ¡ }tj 	|t d| j ¡¡ t j|t|ƒt|jddƒddd ¡ }tj 	|d| j ¡ d S )NTr@   Fr*   )r   rA   rB   r*   r'   r+   r(   r   r   r)   )Úkeys)r   r   r3   rC   r4   r   r   r   r   r   r1   rD   r6   r9   r;   )rE   r    ZWMGr"   r"   r#   Útest_weighted_incidence_matrix£   s„    û
û
	û
û
û
û
û
û
z.TestGraphMatrix.test_weighted_incidence_matrixc                 C   s0  t j t | j¡ ¡ | j¡ t j t | j¡ ¡ | j¡ t j t | j	¡ ¡ | j
¡ t j tj| jddgd ¡ | jdd…dd…f ¡ t j t | j¡ ¡ | j¡ t j tj| jdd ¡ | j¡ t j tj| j	dd ¡ | j
¡ t j tj| jdd ¡ d| j ¡ t j tj| jdd	gd ¡ | j¡ dS )
zConversion to adjacency matrixr   r   r   Nr   )r*   r+   g333333ã?r   )r   r   r   r   Zadjacency_matrixr   r   r2   r   r8   r:   r3   r5   r<   r=   )rE   r"   r"   r#   Útest_adjacency_matrixÿ   s(    *ÿÿÿÿþz%TestGraphMatrix.test_adjacency_matrixN)Ú__name__Ú
__module__Ú__qualname__Úclassmethodr?   rF   rH   rI   r"   r"   r"   r#   r%   0   s
   
6;\r%   )r   Zimportorskipr   Znetworkxr   Znetworkx.exceptionr   Znetworkx.generators.degree_seqr   r$   r%   r"   r"   r"   r#   Ú<module>   s   

%