§
    bŠtj/  ã                   óB   — d dl mZ d dlZdgZej        dd„¦   «         ZdS )	é    )ÚcombinationsNÚ
dispersionTç      ð?ç        c                 óž  ‡‡‡‡— ˆˆˆˆfd„}|€r|€3d„ | D ¦   «         }| D ]#}| |         D ]} || ||¦  «        ||         |<   ŒŒ$n‰t                                | |         i ¦  «        }| |         D ]} || ||¦  «        ||<   ŒnL|€=t                                | |         i ¦  «        }| |         D ]} || ||¦  «        ||<   Œn || ||¦  «        }|S )a�  Calculate dispersion between `u` and `v` in `G`.

    A link between two actors (`u` and `v`) has a high dispersion when their
    mutual ties (`s` and `t`) are not well connected with each other.

    Parameters
    ----------
    G : graph
        A NetworkX graph.
    u : node, optional
        The source for the dispersion score (e.g. ego node of the network).
    v : node, optional
        The target of the dispersion score if specified.
    normalized : bool
        If True (default) normalize by the embeddedness of the nodes (u and v).
    alpha, b, c : float
        Parameters for the normalization procedure. When `normalized` is True,
        the dispersion value is normalized by::

            result = ((dispersion + b) ** alpha) / (embeddedness + c)

        as long as the denominator is nonzero.

    Returns
    -------
    nodes : dictionary
        If u (v) is specified, returns a dictionary of nodes with dispersion
        score for all "target" ("source") nodes. If neither u nor v is
        specified, returns a dictionary of dictionaries for all nodes 'u' in the
        graph with a dispersion score for each node 'v'.

    Notes
    -----
    This implementation follows Lars Backstrom and Jon Kleinberg [1]_. Typical
    usage would be to run dispersion on the ego network $G_u$ if $u$ were
    specified.  Running :func:`dispersion` with neither $u$ nor $v$ specified
    can take some time to complete.

    References
    ----------
    .. [1] Romantic Partnerships and the Dispersion of Social Ties:
        A Network Analysis of Relationship Status on Facebook.
        Lars Backstrom, Jon Kleinberg.
        https://arxiv.org/pdf/1310.6753v1.pdf

    c                 ót  •‡— t          | |         ¦  «        Šˆfd„| |         D ¦   «         }||h}t          |d¦  «        }d}|D ]G\  }}‰                     | |         ¦  «        |z
  }	||	vr |	                     | |         ¦  «        r|dz  }ŒHt	          |¦  «        }
|}‰r|‰z   ‰z  }|
‰z   dk    r||
‰z   z  }|S )z=dispersion for all nodes 'v' in a ego network G_u of node 'u'c                 ó   •— h | ]}|‰v ¯|’Œ	S © r
   )Ú.0ÚnÚu_nbrss     €úg/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/networkx/algorithms/centrality/dispersion.pyú	<setcomp>z2dispersion.<locals>._dispersion.<locals>.<setcomp><   s   ø€ Ð/Ð/Ð/�A 1¨ ; ;ˆa ; ; ;ó    é   r   é   )Úsetr   ÚintersectionÚ
isdisjointÚlen)ÚG_uÚuÚvÚSTÚset_uvÚpossibÚtotalÚsÚtÚnbrs_sÚembeddednessÚdispersion_valr   ÚalphaÚbÚcÚ
normalizeds               @€€€€r   Ú_dispersionzdispersion.<locals>._dispersion9   sô   øø€ å�S˜”V‘”ˆØ/Ð/Ð/Ð/˜˜QœÐ/Ñ/Ô/ˆØ�Q�ˆå˜b !Ñ$Ô$ˆØˆØð 	ð 	‰DˆAˆqà×(Ò(¨¨Q¬Ñ0Ô0°6Ñ9ˆFà˜ˆˆà×$Ò$ S¨¤VÑ,Ô,ð à˜Q‘J�Eøå˜2‘w”wˆàˆØð 	3Ø# a™i¨EÑ1ˆNØ˜aÑ 1Ò$Ð$Ø ,°Ñ"2Ñ2�àÐr   Nc                 ó   — i | ]}|i “ŒS r
   r
   )r   r   s     r   ú
<dictcomp>zdispersion.<locals>.<dictcomp>X   s   € Ð(Ð(Ð( �q˜"Ð(Ð(Ð(r   )ÚdictÚfromkeys)	ÚGr   r   r&   r#   r$   r%   r'   Úresultss	      ````  r   r   r      sJ  øøøø€ ðbð ð ð ð ð ð ð ð8 	€yàˆ9Ø(Ð( aÐ(Ñ(Ô(ˆGØð 9ð 9�Ø˜1œð 9ð 9�AØ$/ K°°1°aÑ$8Ô$8�G˜A”J˜q‘M�Mð9ð9õ
 —m’m A a¤D¨"Ñ-Ô-ˆGØ�q”Tð 2ð 2�Ø(˜[¨¨A¨qÑ1Ô1�˜‘
�
ð2ð ˆ9Ý—m’m A a¤D¨"Ñ-Ô-ˆGØ�q”Tð 2ð 2�Ø(˜[¨¨A¨qÑ1Ô1�˜‘
�
ð2ð "�k ! Q¨Ñ*Ô*ˆGà€Nr   )NNTr   r   r   )Ú	itertoolsr   ÚnetworkxÚnxÚ__all__Ú_dispatchabler   r
   r   r   ú<module>r3      s^   ðØ "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð àˆ.€ð Ôðbð bð bñ Ôðbð bð br   