o
    ßË·e§  ã                   @   sD   d Z ddlmZ g d¢Zdd„ Zedƒdd„ ƒZedƒd	d
„ ƒZdS )zDegree centrality measures.é    )Únot_implemented_for)Údegree_centralityÚin_degree_centralityÚout_degree_centralityc                    óD   t | ƒdkrdd„ | D ƒS dt | ƒd  ‰ ‡ fdd„|  ¡ D ƒ}|S )aè  Compute the degree centrality for nodes.

    The degree centrality for a node v is the fraction of nodes it
    is connected to.

    Parameters
    ----------
    G : graph
      A networkx graph

    Returns
    -------
    nodes : dictionary
       Dictionary of nodes with degree centrality as the value.

    See Also
    --------
    betweenness_centrality, load_centrality, eigenvector_centrality

    Notes
    -----
    The degree centrality values are normalized by dividing by the maximum
    possible degree in a simple graph n-1 where n is the number of nodes in G.

    For multigraphs or graphs with self loops the maximum degree might
    be higher than n-1 and values of degree centrality greater than 1
    are possible.
    é   c                 S   ó   i | ]}|d “qS ©r   © ©Ú.0Únr
   r
   ú`/var/www/ideatree/venv/lib/python3.10/site-packages/networkx/algorithms/centrality/degree_alg.pyÚ
<dictcomp>%   ó    z%degree_centrality.<locals>.<dictcomp>ç      ð?c                    ó   i | ]	\}}||ˆ  “qS r
   r
   ©r   r   Úd©Úsr
   r   r   (   ó    )ÚlenÚdegree©ÚGÚ
centralityr
   r   r   r      s
   r   Ú
undirectedc                    r   )a9  Compute the in-degree centrality for nodes.

    The in-degree centrality for a node v is the fraction of nodes its
    incoming edges are connected to.

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

    Returns
    -------
    nodes : dictionary
        Dictionary of nodes with in-degree centrality as values.

    Raises
    ------
    NetworkXNotImplemented
        If G is undirected.

    See Also
    --------
    degree_centrality, out_degree_centrality

    Notes
    -----
    The degree centrality values are normalized by dividing by the maximum
    possible degree in a simple graph n-1 where n is the number of nodes in G.

    For multigraphs or graphs with self loops the maximum degree might
    be higher than n-1 and values of degree centrality greater than 1
    are possible.
    r   c                 S   r   r	   r
   r   r
   r
   r   r   P   r   z(in_degree_centrality.<locals>.<dictcomp>r   c                    r   r
   r
   r   r   r
   r   r   S   r   )r   Ú	in_degreer   r
   r   r   r   ,   ó
   #r   c                    r   )a;  Compute the out-degree centrality for nodes.

    The out-degree centrality for a node v is the fraction of nodes its
    outgoing edges are connected to.

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

    Returns
    -------
    nodes : dictionary
        Dictionary of nodes with out-degree centrality as values.

    Raises
    ------
    NetworkXNotImplemented
        If G is undirected.

    See Also
    --------
    degree_centrality, in_degree_centrality

    Notes
    -----
    The degree centrality values are normalized by dividing by the maximum
    possible degree in a simple graph n-1 where n is the number of nodes in G.

    For multigraphs or graphs with self loops the maximum degree might
    be higher than n-1 and values of degree centrality greater than 1
    are possible.
    r   c                 S   r   r	   r
   r   r
   r
   r   r   {   r   z)out_degree_centrality.<locals>.<dictcomp>r   c                    r   r
   r
   r   r   r
   r   r   ~   r   )r   Ú
out_degreer   r
   r   r   r   W   r   r   N)Ú__doc__Únetworkx.utils.decoratorsr   Ú__all__r   r   r   r
   r
   r
   r   Ú<module>   s    %
*