
    Vh                     h    d Z ddlZddlmZmZmZmZ d Zd Z	 G d d      Z
 G d d	      Zd
 Zd Zy)zJUnit tests for the :mod:`networkx.algorithms.approximation.clique` module.    N)clique_removallarge_clique_size
max_cliquemaximum_independent_setc                 F    | j                  |      j                         dk(  S )zReturns True if and only if `nodes` is a clique in `G`.

    `G` is a NetworkX graph. `nodes` is an iterable of nodes in
    `G`.

    r   )subgraphnumber_of_edges)Gnodess     c/home/dcms/DCMS/lib/python3.12/site-packages/networkx/algorithms/approximation/tests/test_clique.pyis_independent_setr      s!     ::e,,.!33    c                 r    | j                  |      }t        |      }|j                         ||dz
  z  dz  k(  S )zReturns True if and only if `nodes` is an independent set
    in `G`.

    `G` is an undirected simple graph. `nodes` is an iterable of
    nodes in `G`.

          )r   lenr	   )r
   r   Hns       r   	is_cliquer      s<     	


5AAA!q1u+"222r   c                   "    e Zd ZdZd Zd Zd Zy)TestCliqueRemovalz`Unit tests for the
    :func:`~networkx.algorithms.approximation.clique_removal` function.

    c                     t        j                         t              \  }}t        |      sJ t	        fd|D              sJ t	        d |D              sJ y )Nc              3   6   K   | ]  }t        |        y wNr   .0cliquer
   s     r   	<genexpr>z7TestCliqueRemoval.test_trivial_graph.<locals>.<genexpr>-        >F9Q'>   c              3   8   K   | ]  }t        |      d k(    yw)r   N)r   )r   r   s     r   r   z7TestCliqueRemoval.test_trivial_graph.<locals>.<genexpr>/   s     :3v;!#:s   )nxtrivial_graphr   r   allselfindependent_setcliquesr
   s      @r   test_trivial_graphz$TestCliqueRemoval.test_trivial_graph)   sX    #1!#4 !!_555>g>>>>:'::::r   c                     t        j                  d      t              \  }}t        |      sJ t	        fd|D              sJ y )N
   c              3   6   K   | ]  }t        |        y wr   r   r   s     r   r   z8TestCliqueRemoval.test_complete_graph.<locals>.<genexpr>5   r    r!   )r#   complete_graphr   r   r%   r&   s      @r   test_complete_graphz%TestCliqueRemoval.test_complete_graph1   sF    b!#1!#4 !!_555>g>>>>r   c                     t        j                  dd      t              \  }}t        |      sJ t	        fd|D              sJ y )Nr,      c              3   6   K   | ]  }t        |        y wr   r   r   s     r   r   z7TestCliqueRemoval.test_barbell_graph.<locals>.<genexpr>;   r    r!   )r#   barbell_graphr   r   r%   r&   s      @r   test_barbell_graphz$TestCliqueRemoval.test_barbell_graph7   sH    R##1!#4 !!_555>g>>>>r   N)__name__
__module____qualname____doc__r*   r/   r4    r   r   r   r   #   s    
;??r   r   c                   "    e Zd ZdZd Zd Zd Zy)TestMaxCliquez[Unit tests for the :func:`networkx.algorithms.approximation.max_clique`
    function.

    c                 ^    t        j                         }t        t        |            dk(  sJ y Nr   )r#   
null_graphr   r   )r'   r
   s     r   test_null_graphzTestMaxClique.test_null_graphD   s$    MMO:a=!Q&&&r   c                 d    t        j                  d      }t        |      }dt        |      k(  sJ y )N   )r#   r.   r   r   )r'   graphmcs      r   r/   z!TestMaxClique.test_complete_graphH   s,    !!"%SW}}r   c                     t        j                  d      }|j                  dd       t        |      }t	        |      dkD  sJ t        j
                  dd      }t        |      }t	        |      dkD  sJ y)zTests that the maximal clique is computed according to maximum
        cardinality of the sets.

        For more information, see pull request #1531.

        r1      r   rA   r   N)r#   r.   add_edger   r   lollipop_graph)r'   r
   r   s      r   test_maximal_by_cardinalityz)TestMaxClique.test_maximal_by_cardinalityN   sf     a 	

1aA6{Qb!$A6{Qr   N)r5   r6   r7   r8   r?   r/   rH   r9   r   r   r;   r;   >   s    
'r   r;   c                  n   t        j                  d      } t        j                  | g d       | j                  dd       | j                  dd       | j	                  d       t        |       dk(  sJ | j                  d       t        |       dk(  sJ | j                  dd	       t        |       d
k(  sJ y )N	   )rJ   r,         r         r1   r         )r#   r.   	add_cyclerF   add_noder   remove_noderemove_edger
   s    r   test_large_clique_sizerV   _   s    
!ALLK JJq!JJq"JJrNQ1$$$MM!Q1$$$MM!QQ1$$$r   c                  ^    t        j                         } t        t        |             dk(  sJ y r=   )r#   Graphr   r   rU   s    r   test_independent_setrY   m   s&    

A&q)*a///r   )r8   networkxr#   !networkx.algorithms.approximationr   r   r   r   r   r   r   r;   rV   rY   r9   r   r   <module>r\      s>    P  4
3? ?6 B%0r   