
    Vh<N                         d dl Z d dlmZ d dlZd dlZd Z G d d      Z G d d      Z G d d	      Z	 G d
 d      Z
 G d d      Z G d d      Z G d d      Z G d d      Zy)    N)partialc                 h    || |fi |}|D ci c]  \  }}}t        t        ||g            | }	}}}|D ci c]  \  }}}t        t        ||g            | }
}}}t        |	      t        |
      k(  sJ |	D ]$  }|	|   t        j                  |
|   d      k(  r$J  y c c}}}w c c}}}w )NgHz>)abs)tuplesortedlenpytestapprox)Gebunchexpectedpredict_funckwargsresultuvscoreexp_dictres_dictps               ^/home/dcms/DCMS/lib/python3.12/site-packages/networkx/algorithms/tests/test_link_prediction.py
_test_funcr   	   s    !V.v.F@HIIAufaVn%u,IHI@FGGAufaVn%u,GHGx=CM))) C{fmmHQKTBBBBC	 JGs
   "B&"B-c                       e Zd Zed        Zd Zd Zd Zej                  j                  dej                  ej                  ej                  f      d        Zd Zd Zd	 Zd
 Zy)TestResourceAllocationIndexc                     t        t        j                        | _        t        t	        t
        | j                              | _        y N)r   )staticmethodnxresource_allocation_indexfuncr   r   testclss    r   setup_classz'TestResourceAllocationIndex.setup_class   s+     < <=
 JK    c                 X    t        j                  d      }| j                  |dgdg       y )N   r      )r   r)   g      ?r   complete_graphr!   selfr   s     r   test_K5z#TestResourceAllocationIndex.test_K5   s&    a 		!fX~.r%   c                 X    t        j                  d      }| j                  |dgdg       y )N   r      r   r2         ?r   
path_graphr!   r,   s     r   test_P3z#TestResourceAllocationIndex.test_P3   $    MM!		!fX}-r%   c                 X    t        j                  d      }| j                  |dgdg       y )N   r)   r2   r)   r2   g      ?r   
star_graphr!   r,   s     r   test_S4z#TestResourceAllocationIndex.test_S4!   s$    MM!		!fX~.r%   
graph_typec                 v    t        j                  t        j                  | j                   |ddg      dg       y Nr(   r;   r1   r	   raisesr   NetworkXNotImplementedr    r-   r@   s     r   test_notimplementedz/TestResourceAllocationIndex.test_notimplemented%   /    %%tyy*ff=M2NQWPX	
r%   c                     t        j                         }|j                  g d       t        j                  t         j
                  | j                  |dg       y Nr(   r1   r2   r0   r   r:   r   Graphadd_edges_fromr	   rD   NodeNotFoundr    r,   s     r   test_node_not_foundz/TestResourceAllocationIndex.test_node_not_found+   8    HHJ	12bootyy!fX>r%   c                 |    t        j                         }|j                  ddg       | j                  |dgdg       y Nr   r)   r(   r   r)   r   r   rO   add_nodes_fromr!   r,   s     r   test_no_common_neighborz3TestResourceAllocationIndex.test_no_common_neighbor0   3    HHJ	!Q 		!fX	{+r%   c                 X    t        j                  d      }| j                  |dgdg       y )Nr:   r   r   r   r   r)   r*   r,   s     r   test_equal_nodesz,TestResourceAllocationIndex.test_equal_nodes5   s&    a 		!fX	{+r%   c                 |    t        j                         }|j                  g d       | j                  |d g d       y NrK   )r   r0   r4   )r)   r2   r4   r)   r0   r   r   rO   rP   r!   r,   s     r   test_all_nonexistent_edgesz6TestResourceAllocationIndex.test_all_nonexistent_edges9   -    HHJ	12		!T@Ar%   N__name__
__module____qualname__classmethodr$   r.   r7   r?   r	   markparametrizer   DiGraph
MultiGraphMultiDiGraphrG   rR   rY   r^   rd    r%   r   r   r      ss    L L/./ [[\BJJr+WX
 Y

?
,
,Br%   r   c                       e Zd Zed        Zd Zd Zej                  j                  de
j                  e
j                  e
j                  f      d        Zd Zd Zd Zd	 Zy
)TestJaccardCoefficientc                     t        t        j                        | _        t        t	        t
        | j                              | _        y r   )r   r   jaccard_coefficientr    r   r   r!   r"   s    r   r$   z"TestJaccardCoefficient.setup_class@   s+     6 67
 JKr%   c                 X    t        j                  d      }| j                  |dgdg       y )Nr'   r(   )r   r)   g333333?r*   r,   s     r   r.   zTestJaccardCoefficient.test_K5E   s&    a 		!fX}-r%   c                 X    t        j                  d      }| j                  |dgdg       y )Nr:   r1   r3   r5   r,   s     r   test_P4zTestJaccardCoefficient.test_P4I   r8   r%   r@   c                 v    t        j                  t        j                  | j                   |ddg      dg       y rB   rC   rF   s     r   rG   z*TestJaccardCoefficient.test_notimplementedM   rH   r%   c                     t        j                         }|j                  g d       t        j                  t         j
                  | j                  |dg       y rJ   rN   r,   s     r   rR   z*TestJaccardCoefficient.test_node_not_foundS   rS   r%   c                 |    t        j                         }|j                  ddg       | j                  |dgdg       y )Nr(   rL   r1   r   r2   r   rc   r,   s     r   rY   z.TestJaccardCoefficient.test_no_common_neighborX   s4    HHJ	&&)*		!fX	{+r%   c                 |    t        j                         }|j                  ddg       | j                  |dgdg       y rU   rW   r,   s     r   test_isolated_nodesz*TestJaccardCoefficient.test_isolated_nodes]   rZ   r%   c                 |    t        j                         }|j                  g d       | j                  |d g d       y r`   rc   r,   s     r   rd   z1TestJaccardCoefficient.test_all_nonexistent_edgesb   re   r%   N)rg   rh   ri   rj   r$   r.   rw   r	   rk   rl   r   rm   rn   ro   rG   rR   rY   r}   rd   rp   r%   r   rr   rr   ?   sn    L L.. [[\BJJr+WX
 Y

?
,
,
Br%   rr   c                       e Zd Zed        Zd Zd Zd Zej                  j                  dej                  ej                  ej                  f      d        Zd Zd Zd	 Zd
 Zy)TestAdamicAdarIndexc                     t        t        j                        | _        t        t	        t
        | j                              | _        y r   )r   r   adamic_adar_indexr    r   r   r!   r"   s    r   r$   zTestAdamicAdarIndex.setup_classi   s+     4 45
 JKr%   c           
          t        j                  d      }| j                  |dgdddt        j                  d      z  fg       y )Nr'   r(   r   r)   r0   r:   r   r+   r!   mathlogr,   s     r   r.   zTestAdamicAdarIndex.test_K5n   :    a 		!fXAq488A; 789r%   c           
          t        j                  d      }| j                  |dgdddt        j                  d      z  fg       y )Nr0   r1   r   r2   r)   )r   r6   r!   r   r   r,   s     r   r7   zTestAdamicAdarIndex.test_P3r   8    MM!		!fXAq488A; 789r%   c           
          t        j                  d      }| j                  |dgdddt        j                  d      z  fg       y )Nr:   r;   r)   r2   )r   r>   r!   r   r   r,   s     r   r?   zTestAdamicAdarIndex.test_S4v   r   r%   r@   c                 v    t        j                  t        j                  | j                   |ddg      dg       y rB   rC   rF   s     r   rG   z'TestAdamicAdarIndex.test_notimplementedz   rH   r%   c                     t        j                         }|j                  g d       t        j                  t         j
                  | j                  |dg       y rJ   rN   r,   s     r   rR   z'TestAdamicAdarIndex.test_node_not_found   rS   r%   c                 |    t        j                         }|j                  ddg       | j                  |dgdg       y rU   rW   r,   s     r   rY   z+TestAdamicAdarIndex.test_no_common_neighbor   rZ   r%   c           
          t        j                  d      }| j                  |dgdddt        j                  d      z  fg       y )Nr:   r\   r   r0   r   r,   s     r   r^   z$TestAdamicAdarIndex.test_equal_nodes   r   r%   c                     t        j                         }|j                  g d       | j                  |d dddt	        j
                  d      z  fdddt	        j
                  d      z  fdg       y )NrK   r   r0   r)   r2   rb   )r   rO   rP   r!   r   r   r,   s     r   rd   z.TestAdamicAdarIndex.test_all_nonexistent_edges   s\    HHJ	12		tq!Q!_-1a$((1+o/F	R	
r%   Nrf   rp   r%   r   r   r   h   sr    L L::: [[\BJJr+WX
 Y

?
,
:
r%   r   c                       e Zd Zed        Zd Zd Zd Zej                  j                  dej                  ej                  ej                  f      d        Zd Zd Zd	 Zd
 Zd Zd Zy)TestCommonNeighborCentralityc                     t        t        j                        | _        t        t	        t
        | j                              | _        y r   )r   r   common_neighbor_centralityr    r   r   r!   r"   s    r   r$   z(TestCommonNeighborCentrality.setup_class   s+     = =>
 JKr%   c                     t        j                  d      }| j                  |dgdgd       | j                  |dgdgd       y )Nr'   r(   )r   r)   g      @r)   alpha)r   r)   g      @r   r*   r,   s     r   r.   z$TestCommonNeighborCentrality.test_K5   sB    a 		!fX}A	6		!fX}A	6r%   c                 \    t        j                  d      }| j                  |dgdgd       y )Nr0   r1   )r   r2   g      ?r4   r   r5   r,   s     r   r7   z$TestCommonNeighborCentrality.test_P3   (    MM!		!fX~S	9r%   c                 \    t        j                  d      }| j                  |dgdgd       y )Nr:   r;   )r)   r2   g      ?r4   r   r=   r,   s     r   r?   z$TestCommonNeighborCentrality.test_S4   r   r%   r@   c                 v    t        j                  t        j                  | j                   |ddg      dg       y rB   rC   rF   s     r   rG   z0TestCommonNeighborCentrality.test_notimplemented   rH   r%   c                     t        j                         }|j                  ddg       t        j                  t         j
                  | j                  |dg       y )Nr)   r0   rL   r(   rN   r,   s     r   test_node_u_not_foundz2TestCommonNeighborCentrality.test_node_u_not_found   s<    HHJ	&&)*bootyy!fX>r%   c                     t        j                         }|j                  g d       t        j                  t         j
                  | j                  |dg       y rJ   rN   r,   s     r   test_node_v_not_foundz2TestCommonNeighborCentrality.test_node_v_not_found   rS   r%   c                 |    t        j                         }|j                  ddg       | j                  |dgdg       y rU   rW   r,   s     r   rY   z4TestCommonNeighborCentrality.test_no_common_neighbor   rZ   r%   c                     t        j                  d      }t        j                  t         j                  | j
                  |dgg        y )Nr:   r\   r   r+   r	   rD   NetworkXAlgorithmErrorr!   r,   s     r   r^   z-TestCommonNeighborCentrality.test_equal_nodes   s2    a b//AxLr%   c                     t        j                  d      }t        j                  t         j                  | j
                  |dgg d       y )Nr:   r\   g      ?r   r   r,   s     r   ,test_equal_nodes_with_alpha_one_raises_errorzITestCommonNeighborCentrality.test_equal_nodes_with_alpha_one_raises_error   s5    a b//AxSVWr%   c                     t        j                         }|j                  g d       | j                  |d g dd       y )NrK   ))r   r0         ?)r)   r2   r   )r)   r0   gUUUUUU?r4   r   rc   r,   s     r   rd   z7TestCommonNeighborCentrality.test_all_nonexistent_edges   s1    HHJ	12		!TDC	Pr%   N)rg   rh   ri   rj   r$   r.   r7   r?   r	   rk   rl   r   rm   rn   ro   rG   r   r   rY   r^   r   rd   rp   r%   r   r   r      s    L L7
:: [[\BJJr+WX
 Y

?
?
,
MXQr%   r   c                       e Zd Zed        Zd Zd Zd Zej                  j                  dej                  ej                  ej                  f      d        Zd Zd Zd	 Zy
)TestPreferentialAttachmentc                     t        t        j                        | _        t        t	        t
        | j                              | _        y r   )r   r   preferential_attachmentr    r   r   r!   r"   s    r   r$   z&TestPreferentialAttachment.setup_class   s+     : :;
 JKr%   c                 X    t        j                  d      }| j                  |dgdg       y )Nr'   r(   )r   r)      r*   r,   s     r   r.   z"TestPreferentialAttachment.test_K5   s&    a 		!fX
|,r%   c                 X    t        j                  d      }| j                  |dgdg       y )Nr0   r(   r   r)   r2   r5   r,   s     r   r7   z"TestPreferentialAttachment.test_P3   $    MM!		!fX	{+r%   c                 X    t        j                  d      }| j                  |dgdg       y )Nr:   r1   )r   r2   r:   r=   r,   s     r   r?   z"TestPreferentialAttachment.test_S4   r   r%   r@   c                 v    t        j                  t        j                  | j                   |ddg      dg       y rB   rC   rF   s     r   rG   z.TestPreferentialAttachment.test_notimplemented   rH   r%   c                     t        j                         }|j                  g d       t        j                  t         j
                  | j                  |dg       y rJ   rN   r,   s     r   rR   z.TestPreferentialAttachment.test_node_not_found   rS   r%   c                 |    t        j                         }|j                  ddg       | j                  |dgdg       y rU   rW   r,   s     r   test_zero_degreesz,TestPreferentialAttachment.test_zero_degrees   rZ   r%   c                 |    t        j                         }|j                  g d       | j                  |d g d       y )NrK   )r   r0   r2   r)   r2   r2   )r)   r0   r)   rc   r,   s     r   rd   z5TestPreferentialAttachment.test_all_nonexistent_edges   s-    HHJ	12		!T<=r%   N)rg   rh   ri   rj   r$   r.   r7   r?   r	   rk   rl   r   rm   rn   ro   rG   rR   r   rd   rp   r%   r   r   r      sm    L L-,, [[\BJJr+WX
 Y

?
,
>r%   r   c                       e Zd Zed        Zd Zd Zd Zej                  j                  dej                  ej                  ej                  f      d        Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zy)TestCNSoundarajanHopcroftc                     t        t        j                        | _        t        t	        t
        | j                  d            | _        y N	community)r   r   )r   r   cn_soundarajan_hopcroftr    r   r   r!   r"   s    r   r$   z%TestCNSoundarajanHopcroft.setup_class   s0     : :;JSXXM
r%   c                    t        j                  d      }d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j                  |dgd	g       y )
Nr'   r   r   r)   r2   r0   r:   r(   )r   r)   r'   r   r+   nodesr!   r,   s     r   r.   z!TestCNSoundarajanHopcroft.test_K5   s    a "#
;"#
;"#
;"#
;"#
;		!fX	{+r%   c                     t        j                  d      }d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j                  |dgdg       y )Nr0   r   r   r)   r2   r1   )r   r2   r)   r   r6   r   r!   r,   s     r   r7   z!TestCNSoundarajanHopcroft.test_P3  Z    MM!"#
;"#
;"#
;		!fX	{+r%   c                    t        j                  d      }d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j                  |dgdg       y )	Nr:   r)   r   r   r2   r0   r;   r   r   r>   r   r!   r,   s     r   r?   z!TestCNSoundarajanHopcroft.test_S4  s~    MM!"#
;"#
;"#
;"#
;"#
;		!fX	{+r%   r@   c                      |ddg      }|j                  g dd       t        j                  t        j                  | j
                  |dg       y Nr(   r;   r   r   r   r1   rX   r	   rD   r   rE   r    r-   r@   r   s      r   rG   z-TestCNSoundarajanHopcroft.test_notimplemented  B    '(	a0b//AxHr%   c                 D   t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   t	        j
                  t         j                  | j                  |dg       y NrK   r   r   r)   r2   r0   rM   r   rO   rP   r   r	   rD   rQ   r    r,   s     r   rR   z-TestCNSoundarajanHopcroft.test_node_not_found      HHJ	12"#
;"#
;"#
;"#
;bootyy!fX>r%   c                     t        j                         }|j                  ddg       d|j                  d   d<   d|j                  d   d<   | j	                  |dgdg       y Nr   r)   r   r(   rV   r   rO   rX   r   r!   r,   s     r   rY   z1TestCNSoundarajanHopcroft.test_no_common_neighbor$  W    HHJ	!Q "#
;"#
;		!fX	{+r%   c                     t        j                  d      }d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j                  |dgdg       y )Nr0   r   r   r)   r2   r\   )r   r   r:   r   r,   s     r   r^   z*TestCNSoundarajanHopcroft.test_equal_nodes+  \    a "#
;"#
;"#
;		!fX	{+r%   c                    t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j	                  |dgdg       y )	Nr(   r1   r   rL   r   r   r)   r2   r0   r   r0   r   r   rO   rP   r   r!   r,   s     r   test_different_communityz2TestCNSoundarajanHopcroft.test_different_community2  x    HHJ	9:"#
;"#
;"#
;"#
;		!fX	{+r%   c                     t        j                  d      }t        j                  t         j                  t
        | j                  |dg             y Nr'   r(   r   r+   r	   rD   r   listr    r,   s     r   test_no_community_informationz7TestCNSoundarajanHopcroft.test_no_community_information;  5    a b//tyyVH7MNr%   c                 2   t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   t	        j
                  t         j                  t        | j                  |dg             y Nr   r   r   r)   r0   r   	r   rO   rP   r   r	   rD   r   r   r    r,   s     r   'test_insufficient_community_informationzATestCNSoundarajanHopcroft.test_insufficient_community_information?  u    HHJ	9:"#
;"#
;"#
;b//tyyVH7MNr%   c                    t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j	                  |dgd	g       y )
Nr(   r;   r   )r2   r:   )r0   r:   )r:   r'   r   r)   r   r2   r0   r:   r)   r:   )r)   r:   r:   r   r,   s     r   %test_sufficient_community_informationz?TestCNSoundarajanHopcroft.test_sufficient_community_informationG  x    HHJ	IJ"#
;"#
;"#
;"#
;		!fX	{+r%   c                    t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j	                  |dgdgd	       y )
Nr   r   cmtyr)   r2   r0   r   r   r   r   r,   s     r   $test_custom_community_attribute_namez>TestCNSoundarajanHopcroft.test_custom_community_attribute_nameP  |    HHJ	9:
6
6
6
6		!fX	{f	=r%   c                    t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j	                  |d g d       y )NrK   r   r   r)   r2   r0   )r   )r)   r2   r)   rb   r   r,   s     r   rd   z4TestCNSoundarajanHopcroft.test_all_nonexistent_edgesY  su    HHJ	12"#
;"#
;"#
;"#
;		!T<=r%   Nrg   rh   ri   rj   r$   r.   r7   r?   r	   rk   rl   r   rm   rn   ro   rG   rR   rY   r^   r   r   r   r   r   rd   rp   r%   r   r   r      s    
 
,,, [[\BJJr+WXI YI
?,,,OO,>>r%   r   c                       e Zd Zed        Zd Zd Zd Zej                  j                  dej                  ej                  ej                  f      d        Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zy)TestRAIndexSoundarajanHopcroftc                     t        t        j                        | _        t        t	        t
        | j                  d            | _        y r   )r   r   ra_index_soundarajan_hopcroftr    r   r   r!   r"   s    r   r$   z*TestRAIndexSoundarajanHopcroft.setup_classd  s0     @ @AJSXXM
r%   c                    t        j                  d      }d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j                  |dgd	g       y )
Nr'   r   r   r)   r2   r0   r:   r(   )r   r)   r4   r   r,   s     r   r.   z&TestRAIndexSoundarajanHopcroft.test_K5k  s    a "#
;"#
;"#
;"#
;"#
;		!fX}-r%   c                     t        j                  d      }d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j                  |dgdg       y Nr0   r   r   r)   r2   r1   r{   r   r,   s     r   r7   z&TestRAIndexSoundarajanHopcroft.test_P3t  r   r%   c                    t        j                  d      }d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j                  |dgdg       y )	Nr:   r)   r   r   r2   r0   r;   r<   r   r,   s     r   r?   z&TestRAIndexSoundarajanHopcroft.test_S4{  s~    MM!"#
;"#
;"#
;"#
;"#
;		!fX~.r%   r@   c                      |ddg      }|j                  g dd       t        j                  t        j                  | j
                  |dg       y r   r   r   s      r   rG   z2TestRAIndexSoundarajanHopcroft.test_notimplemented  r   r%   c                 D   t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   t	        j
                  t         j                  | j                  |dg       y r   r   r,   s     r   rR   z2TestRAIndexSoundarajanHopcroft.test_node_not_found  r   r%   c                     t        j                         }|j                  ddg       d|j                  d   d<   d|j                  d   d<   | j	                  |dgdg       y r   r   r,   s     r   rY   z6TestRAIndexSoundarajanHopcroft.test_no_common_neighbor  r   r%   c                     t        j                  d      }d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j                  |dgdg       y )Nr0   r   r   r)   r2   r\   r]   r   r,   s     r   r^   z/TestRAIndexSoundarajanHopcroft.test_equal_nodes  r   r%   c                    t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j	                  |dgdg       y 	Nr   r   r   r)   r2   r0   r   r   r0   r   r   r,   s     r   r   z7TestRAIndexSoundarajanHopcroft.test_different_community  r   r%   c                     t        j                  d      }t        j                  t         j                  t
        | j                  |dg             y r   r   r,   s     r   r   z<TestRAIndexSoundarajanHopcroft.test_no_community_information  r   r%   c                 2   t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   t	        j
                  t         j                  t        | j                  |dg             y r   r   r,   s     r   r   zFTestRAIndexSoundarajanHopcroft.test_insufficient_community_information  r   r%   c                    t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j	                  |dgd	g       y )
Nr   r   r)   r   r2   r0   r:   r   )r)   r:   r)   r   r,   s     r   r   zDTestRAIndexSoundarajanHopcroft.test_sufficient_community_information  r   r%   c                    t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j	                  |dgdgd	       y )
Nr   r   r   r)   r2   r0   r   r  r   r   r,   s     r   r   zCTestRAIndexSoundarajanHopcroft.test_custom_community_attribute_name  r   r%   c                    t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j	                  |d g d       y )NrK   r   r   r)   r2   r0   )ra   r)   r2   r   rb   r   r,   s     r   rd   z9TestRAIndexSoundarajanHopcroft.test_all_nonexistent_edges  su    HHJ	12"#
;"#
;"#
;"#
;		!T>?r%   Nr   rp   r%   r   r   r   c  s    
 
.,/ [[\BJJr+WXI YI
?,,,OO,>@r%   r   c                       e Zd Zed        Zd Zd Zd Zej                  j                  dej                  ej                  ej                  f      d        Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zy)TestWithinInterClusterc                     d| _         t        t        j                        | _        t        t        t        | j                  | j                   d            | _        y )NgMbP?r   )r   deltar   )r  r   r   within_inter_clusterr    r   r   r!   r"   s    r   r$   z"TestWithinInterCluster.setup_class  sC    	 7 78 XXii%	
r%   c           	      2   t        j                  d      }d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j                  |dgdddd| j                  z   z  fg       y )	Nr'   r   r   r)   r2   r0   r:   r(   r   r+   r   r!   r  r,   s     r   r.   zTestWithinInterCluster.test_K5  s    a "#
;"#
;"#
;"#
;"#
;		!fXAqA

N'; <=>r%   c                     t        j                  d      }d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j                  |dgdg       y r   r   r,   s     r   r7   zTestWithinInterCluster.test_P3  r   r%   c                 ,   t        j                  d      }d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j                  |dgddd| j                  z  fg       y )Nr:   r)   r   r   r2   r0   r;   )r   r>   r   r!   r  r,   s     r   r?   zTestWithinInterCluster.test_S4  s    MM!"#
;"#
;"#
;"#
;"#
;		!fXAq4::~ 678r%   r@   c                      |ddg      }|j                  g dd       t        j                  t        j                  | j
                  |dg       y r   r   r   s      r   rG   z*TestWithinInterCluster.test_notimplemented  r   r%   c                 D   t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   t	        j
                  t         j                  | j                  |dg       y r   r   r,   s     r   rR   z*TestWithinInterCluster.test_node_not_found  r   r%   c                     t        j                         }|j                  ddg       d|j                  d   d<   d|j                  d   d<   | j	                  |dgdg       y r   r   r,   s     r   rY   z.TestWithinInterCluster.test_no_common_neighbor  r   r%   c                     t        j                  d      }d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j                  |dgddd| j                  z  fg       y )Nr0   r   r   r)   r2   r\   r  r,   s     r   r^   z'TestWithinInterCluster.test_equal_nodes  sl    a "#
;"#
;"#
;		!fXAq4::~ 678r%   c                    t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j	                  |dgdg       y r   r   r,   s     r   r   z/TestWithinInterCluster.test_different_community  r   r%   c                    t        j                  d      }d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j                  |dgddd| j                  z  fg       y )Nr:   r   r   r)   r2   r0   r   r  r,   s     r   %test_no_inter_cluster_common_neighborz<TestWithinInterCluster.test_no_inter_cluster_common_neighbor  s~    a "#
;"#
;"#
;"#
;		!fXAq4::~ 678r%   c                     t        j                  d      }t        j                  t         j                  t
        | j                  |dg             y r   r   r,   s     r   r   z4TestWithinInterCluster.test_no_community_information'  r   r%   c                 2   t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   t	        j
                  t         j                  t        | j                  |dg             y r   r   r,   s     r   r   z>TestWithinInterCluster.test_insufficient_community_information+  r   r%   c                 ,   t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j	                  |dgddd| j
                  z  fg       y )	Nr   r   r)   r   r2   r0   r:   r   r   rO   rP   r   r!   r  r,   s     r   r   z<TestWithinInterCluster.test_sufficient_community_information3  s    HHJ	IJ"#
;"#
;"#
;"#
;		!fXAq4::~ 678r%   c                     t        j                  d      }|j                  g dd       t        j                  t         j
                  | j                  |dgd       t        j                  t         j
                  | j                  |dgd       y )Nr0   r   r   r   r(   g      )r   r+   rX   r	   rD   r   r    r,   s     r   test_invalid_deltaz)TestWithinInterCluster.test_invalid_delta<  se    a 	a0b//AxKb//AxNr%   c                    t        j                  d      }d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j                  |dgddd| j                  z  fgd       y )	Nr:   r   r   r)   r2   r0   r   r   r  r,   s     r   r   z;TestWithinInterCluster.test_custom_community_attribute_nameB  s    a 
6
6
6
6		!fXAq4::~ 676	Jr%   c                 .   t        j                         }|j                  g d       d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   d|j                  d   d<   | j	                  |d ddd| j
                  z  fddg       y )	NrK   r   r   r)   r2   r0   r  rb   r  r,   s     r   rd   z1TestWithinInterCluster.test_all_nonexistent_edgesJ  s    HHJ	12"#
;"#
;"#
;"#
;		!TQ1tzz>2IyIJr%   N)rg   rh   ri   rj   r$   r.   r7   r?   r	   rk   rl   r   rm   rn   ro   rG   rR   rY   r^   r   r  r   r   r   r  r   rd   rp   r%   r   r	  r	    s    

 

?,9 [[\BJJr+WXI YI
?,9,9OO9OKKr%   r	  )r   	functoolsr   r	   networkxr   r   r   rr   r   r   r   r   r   r	  rp   r%   r   <module>r"     s~       C)B )BX&B &BR+
 +
\3Q 3Ql%> %>Pl> l>^l@ l@^K Kr%   