
    \Mh	                     H    d dl mZ d dlZdgZej        dd            Zd ZdS )    )defaultdictNk_clique_communitiesc              #   N  K   dk     rt          j        d d          |t          j        |           }fd|D             }t          t                    }|D ]"}|D ]}||                             |           #t          j                    }|                    |           |D ]T}t          ||          D ]A}t          |
                    |                    dz
  k    r|                    ||           BUt          j        |          D ]}t          j        | V  dS )u8  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.Nc                 T    g | ]$}t          |          k    t          |          %S  )len	frozenset).0cks     e/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/networkx/algorithms/community/kclique.py
<listcomp>z(k_clique_communities.<locals>.<listcomp>3   s*    <<<A!y||       )nxNetworkXErrorfind_cliquesr   listappendGraphadd_nodes_from_get_adjacent_cliquesr	   intersectionadd_edgeconnected_componentsr
   union)	Gr   cliquesmembership_dictcliquenode
perc_graph
adj_clique	components	    `       r   r   r      sq     N 	1uuBABBBCCC/!$$<<<<W<<<G "$''O 1 1 	1 	1DD!((0000	1 Jg&&& 8 8/HH 	8 	8J6&&z2233A>>##FJ777	8 ,Z88 , ,		*++++, ,r   c                 x    t                      }| D ](}||         D ]}| |k    r|                    |           )|S N)setadd)r!   r    adjacent_cliquesnr$   s        r   r   r   I   s\    uu 1 1)!, 	1 	1J## $$Z000	1 r   r'   )collectionsr   networkxr   __all___dispatchabler   r   r   r   r   <module>r0      si    # # # # # #    !
" =, =, =, =,@    r   