
    h	                     L    S SK Jr  S SKrS/r\R
                  SS j5       rS rg)    )defaultdictNk_clique_communitiesc              #     #    US:  a  [         R                  " SU S35      eUc  [         R                  " U 5      nU Vs/ s H  n[        U5      U:  d  M  [	        U5      PM!     nn[        [        5      nU H  nU H  nXF   R                  U5        M     M!     [         R                  " 5       nUR                  U5        U HI  n[        XT5       H7  n[        UR                  U5      5      US-
  :  d  M&  UR                  XX5        M9     MK     [         R                  " U5       H  n	[        R                  " U	6 v   M     gs  snf 7f)u  Find k-clique communities in graph using the percolation method.

A k-clique community is the union of all cliques of size k that
can be reached through adjacent (sharing k-1 nodes) k-cliques.

Parameters
----------
G : NetworkX graph

k : int
   Size of smallest clique

cliques: list or generator
   Precomputed cliques (use networkx.find_cliques(G))

Returns
-------
Yields sets of nodes, one for each k-clique community.

Examples
--------
>>> G = nx.complete_graph(5)
>>> K5 = nx.convert_node_labels_to_integers(G, first_label=2)
>>> G.add_edges_from(K5.edges())
>>> c = list(nx.community.k_clique_communities(G, 4))
>>> sorted(list(c[0]))
[0, 1, 2, 3, 4, 5, 6]
>>> list(nx.community.k_clique_communities(G, 6))
[]

References
----------
.. [1] Gergely Palla, Imre Derényi, Illés Farkas1, and Tamás Vicsek,
   Uncovering the overlapping community structure of complex networks
   in nature and society Nature 435, 814-818, 2005,
   doi:10.1038/nature03607
   zk=z, k must be greater than 1.N   )nxNetworkXErrorfind_cliqueslen	frozensetr   listappendGraphadd_nodes_from_get_adjacent_cliquesintersectionadd_edgeconnected_componentsunion)
Gkcliquescmembership_dictcliquenode
perc_graph
adj_clique	components
             W/var/www/html/env/lib/python3.13/site-packages/networkx/algorithms/community/kclique.pyr   r      s    N 	1uA3&ABCC//!$%,<WA!|y|WG< "$'OD!((0  
 Jg&/HJ6&&z23A>##F7 I  ,,Z8		*+ 9% =s   >E	 EE&BE	8AE	c                 r    [        5       nU  H&  nX    H  nX:w  d  M
  UR                  U5        M     M(     U$ N)setadd)r   r   adjacent_cliquesnr   s        r    r   r   I   s=    u),J# $$Z0 -      r"   )collectionsr   networkxr   __all___dispatchabler   r    r'   r    <module>r-      s3    # !
" =, =,@r'   