
    fi<                         d Z ddlZddlmZ g dZej        d             Z ed          ej        d                         Z ed          ej        d                         Z	dS )	zDegree centrality measures.    N)not_implemented_for)degree_centralityin_degree_centralityout_degree_centralityc                     t          |           dk    rt                              | d          S dt          |           dz
  z  f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.

    Examples
    --------
    >>> G = nx.Graph([(0, 1), (0, 2), (0, 3), (1, 2), (1, 3)])
    >>> nx.degree_centrality(G)
    {0: 1.0, 1: 1.0, 2: 0.6666666666666666, 3: 0.6666666666666666}

    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                 "    i | ]\  }}||z  S  r   .0ndss      /var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/networkx/algorithms/centrality/degree_alg.py
<dictcomp>z%degree_centrality.<locals>.<dictcomp>1   s#    222tq!!QU222    )lendictfromkeysdegreeG
centralityr   s     @r   r   r   	   sd    H 1vv{{}}Q"""s1vv|A2222qxxzz222Jr   
undirectedc                     t          |           dk    rt                              | d          S dt          |           dz
  z  fd|                                 D             }|S )a
  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.

    Examples
    --------
    >>> G = nx.DiGraph([(0, 1), (0, 2), (0, 3), (1, 2), (1, 3)])
    >>> nx.in_degree_centrality(G)
    {0: 0.0, 1: 0.3333333333333333, 2: 0.6666666666666666, 3: 0.6666666666666666}

    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   r	   c                 "    i | ]\  }}||z  S r   r   r   s      r   r   z(in_degree_centrality.<locals>.<dictcomp>c   s#    555tq!!QU555r   )r   r   r   	in_degreer   s     @r   r   r   5   sd    T 1vv{{}}Q"""s1vv|A5555q{{}}555Jr   c                     t          |           dk    rt                              | d          S dt          |           dz
  z  fd|                                 D             }|S )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.

    Examples
    --------
    >>> G = nx.DiGraph([(0, 1), (0, 2), (0, 3), (1, 2), (1, 3)])
    >>> nx.out_degree_centrality(G)
    {0: 1.0, 1: 0.6666666666666666, 2: 0.0, 3: 0.0}

    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   r	   c                 "    i | ]\  }}||z  S r   r   r   s      r   r   z)out_degree_centrality.<locals>.<dictcomp>   s#    666tq!!QU666r   )r   r   r   
out_degreer   s     @r   r   r   g   sd    T 1vv{{}}Q"""s1vv|A6666q||~~666Jr   )
__doc__networkxnxnetworkx.utils.decoratorsr   __all___dispatchabler   r   r   r   r   r   <module>r(      s    ! !     9 9 9 9 9 9
P
P
P ( ( (V \""- -  #"-` \""- -  #"- - -r   