o
    3ήco                     @   sh   d dl mZ d dlZd dlZd dlmZ dZdZddd	Z	dd
dZ
dd Zdd Zdd Zdd ZdS )    )productN)lukes_partitioninge_weightn_weightFTc                 C   s   d}| rd}nd}|rt  }nt  }|jdi td| i |jdi td| i |jdi td| i |jdi td| i |rPt |dt t}nd }d	d
 t|||tdD }|S )N   gMbP?r                  c                 S      h | ]}t |qS  	frozenset.0xr   r   U/tmp/pip-target-vg8gfxp4/lib/python/networkx/algorithms/community/tests/test_lukes.py	<setcomp>+       zpaper_1_case.<locals>.<setcomp>node_weightedge_weightr   r   r   r	   r   r   r   r
   )nxDiGraphGraphadd_edgeEWLset_node_attributesNWLr   )float_edge_wtexplicit_node_wtdirectedlimitshift	example_1wtu
clusters_1r   r   r   paper_1_case   s&   
r,   c                 C   s  d}|r	t  }nt  }| rtdi}t}ni }d }|jdi | |jdi | |jdi | |jdi | |jdi | |jdi | |jdi | |jdi | |jdi | |jdi | d|jd t< d|jd t< d|jd t< d|jd t< d|jd t< d|jd t< d|jd	 t< d|jd
 t< d|jd t< d|jd t< d|jd t< dd t||t|dD }|S )N    r   namehome_address	educationbsmsphd	telephonehomeofficeno1no2   
      r	   c                 S   r   r   r   r   r   r   r   r   _   r   zpaper_2_case.<locals>.<setcomp>r   )r.   r/   )r.   r0   )r0   r1   )r0   r2   )r0   r3   )r.   r4   )r4   r5   )r4   r6   )r6   r7   )r6   r8   )r   r   r   r!   r    nodesr#   r   )explicit_edge_wtr&   byte_block_size	example_2edicr*   
clusters_2r   r   r   paper_2_case4   sH   
rB   c                  C   sP   t ddgt g dh} d}t|||D ]\}}}t|||}|| ks%J qd S )Nr   r	   )r   r   r
   TF)r   r   r,   )ground_truthtffltnwtdrcpartr   r   r   test_paper_1_casei   s   rJ   c                  C   sT   t g dt ddgt g dh} d}t||D ]\}}t||}|| ks'J qd S )N)r0   r1   r2   r3   r.   r/   )r4   r5   r6   r7   r8   rC   )r   r   rB   )rD   rE   ewtrH   rI   r   r   r   test_paper_2_caser   s   



rL   c                  C   sF   t d} tt j t| d W d    d S 1 sw   Y  d S )Nr	   r
   )r   complete_graphpytestraisesNotATreer   )
not_a_treer   r   r   test_mandatory_tree   s   
"rR   c                  C   s   d} t  }|jdi tdi |jdi tdi |jdi tdi |jdi td
i d|jd t< d|jd t< d|jd t< d|jd t< d|jd	 t< tt t	|| ttd W d    d S 1 sjw   Y  d S )Nr-   r   r   g	@r	   g333333@r   g      @r
   g333333@g333333?r   r   r   r   r   )
r   r   r    r!   r<   r#   rN   rO   	TypeErrorr   )r>   ex_1_brokenr   r   r   test_mandatory_integrality   s    "rU   )FTFrC   )	itertoolsr   rN   networkxr   networkx.algorithms.communityr   r!   r#   r,   rB   rJ   rL   rR   rU   r   r   r   r   <module>   s    

'5	