3
Médc  ã               @   s   d Z dgZdd„ ZdS )z2Helper functions for community-finding algorithms.Úis_partitionc                sR   t |tƒst|ƒ}‡ fdd„|D ƒ}tˆ ƒt|ƒ  koLtdd„ |D ƒƒkS   S )aŸ  Returns *True* if `communities` is a partition of the nodes of `G`.

    A partition of a universe set is a family of pairwise disjoint sets
    whose union is the entire universe set.

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

    communities : list or iterable of sets of nodes
        If not a list, the iterable is converted internally to a list.
        If it is an iterator it is exhausted.

    c                s"   h | ]}|D ]}|ˆ kr|’qqS © r   )Ú.0ÚcÚn)ÚGr   ú_/var/www/html/virt/lib/python3.6/site-packages/networkx/algorithms/community/community_utils.pyú	<setcomp>   s    zis_partition.<locals>.<setcomp>c             s   s   | ]}t |ƒV  qd S )N)Úlen)r   r   r   r   r   ú	<genexpr>   s    zis_partition.<locals>.<genexpr>)Ú
isinstanceÚlistr	   Úsum)r   ZcommunitiesZnodesr   )r   r   r      s    
N)Ú__doc__Ú__all__r   r   r   r   r   Ú<module>   s   