U
    -e+                     @   sB   d dl Z e dZe d d dlZd dlmZ G dd dZdS )    NnumpyZscipy)havel_hakimi_graphc                   @   s0   e Zd Zedd Zdd Zdd Zdd Zd	S )
TestModularityc                 C   s2   dddddg}t || _t | _| jd d S )N         r   )
)r   r   )r   r   )r   r   )r   r   )r      )   r   )r	      )r   r	   )r   r
   )r
   r	   )r   GnxZDiGraphDGZadd_edges_from)clsdeg r   f/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/networkx/linalg/tests/test_modularity.pysetup_class   s    

zTestModularity.setup_classc                 C   s   t dddddgdddddgdddddgdddddgdddddgg}d	d
dddg}t jt| j| t jtj| j|d|t ||  dS )zModularity matrix            ?      ?                    ?      п      r	   r   r   r   r   ZnodelistN)nparraytestingassert_equalr   modularity_matrixr   ix_)selfBZpermutationr   r   r   test_modularity!   s    zTestModularity.test_modularityc                 C   s   t dddddgdddddgdddddgdddddgdddddgg}| j }| D ]\}}d|j||f d	< qXt jt|| t jtj|d	d
d|  dS )zModularity matrix with weightsr   r   r   r   r   r   r   r   weight)r%   N)	r   r   r   copyedgesr   r   r   r    )r"   r#   Z
G_weightedZn1Zn2r   r   r   test_modularity_weight2   s    
 z%TestModularity.test_modularity_weightc                 C   s   t ddddddgddddddgdddd	dd	gddddddgddddddgd
dd
dddgg}ddddddg}ddddddg}tj| jt| jd}t j|| t jtj| j|d|t ||  dS )zDirected Modularity matrixgɿg333333?g?gٿr   gffffff?g?g333333ӿg333333gr   r   r   r   r	   r
   r   r   N)	r   r   r   Zdirected_modularity_matrixr   sortedr   r   r!   )r"   r#   Znode_permutationZidx_permutationmmr   r   r   test_directed_modularityF   s    z'TestModularity.test_directed_modularityN)__name__
__module____qualname__classmethodr   r$   r(   r+   r   r   r   r   r   
   s
   
r   )ZpytestZimportorskipr   Znetworkxr   Znetworkx.generators.degree_seqr   r   r   r   r   r   <module>   s
   

