§
    bŠtj  ã                   óZ   — d Z ddlmZ ddlZdgZ ej        d¬¦  «        dd„¦   «         ZdS )	z;Functions for computing the harmonic centrality of a graph.é    )ÚpartialNÚharmonic_centralityÚdistance)Ú
edge_attrsc                 ó<  — t          |�|                      |¦  «        n| j        ¦  «        }t          |�|                      |¦  «        n| j        ¦  «        }d„ |D ¦   «         }d}t          |¦  «        t          |¦  «        k     r0d}||}}t	          j        | ¦  «        rt	          j        | d¬¦  «        } t          t          j        | |¬¦  «        }|D ]H} ||¦  «        }| 	                    ¦   «         D ]&\  }	}
|
dk    r|	|v r||r|n|	xx         d|
z  z  cc<   Œ'ŒI|S )	a%  Compute harmonic centrality for nodes.

    Harmonic centrality [1]_ of a node `u` is the sum of the reciprocal
    of the shortest path distances from all other nodes to `u`

    .. math::

        C(u) = \sum_{v \neq u} \frac{1}{d(v, u)}

    where `d(v, u)` is the shortest-path distance between `v` and `u`.

    If `sources` is given as an argument, the returned harmonic centrality
    values are calculated as the sum of the reciprocals of the shortest
    path distances from the nodes specified in `sources` to `u` instead
    of from all nodes to `u`.

    Notice that higher values indicate higher centrality.

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

    nbunch : container (default: all nodes in G)
      Container of nodes for which harmonic centrality values are calculated.

    sources : container (default: all nodes in G)
      Container of nodes `v` over which reciprocal distances are computed.
      Nodes not in `G` are silently ignored.

    distance : edge attribute key, optional (default=None)
      Use the specified edge attribute as the edge distance in shortest
      path calculations.  If `None`, then each edge will have distance equal to 1.

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

    See Also
    --------
    betweenness_centrality, load_centrality, eigenvector_centrality,
    degree_centrality, closeness_centrality

    Notes
    -----
    If the 'distance' keyword is set to an edge attribute key then the
    shortest-path length will be computed using Dijkstra's algorithm with
    that edge attribute as the edge weight.

    References
    ----------
    .. [1] Boldi, Paolo, and Sebastiano Vigna. "Axioms for centrality."
           Internet Mathematics 10.3-4 (2014): 222-262.
    Nc                 ó   — i | ]}|d “ŒS )r   © )Ú.0Úus     úe/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/networkx/algorithms/centrality/harmonic.pyú
<dictcomp>z'harmonic_centrality.<locals>.<dictcomp>G   s   € Ð'Ð'Ð'˜1�!�QÐ'Ð'Ð'ó    FT)Úcopy)Úweightr   é   )
ÚsetÚnbunch_iterÚnodesÚlenÚnxÚis_directedÚreverser   Úshortest_path_lengthÚitems)ÚGÚnbunchr   ÚsourcesÚ
centralityÚ
transposedÚsplÚvÚdistr   Úd_uvs              r   r   r   
   sH  € õt ¨&Ð*<�—’˜vÑ&Ô&Ð&À!Ä'ÑJÔJ€FÝ¨GÐ,?�!—-’- Ñ(Ô(Ð(ÀQÄWÑMÔM€Gà'Ð' Ð'Ñ'Ô'€Jà€JÝ
ˆ6�{„{•S˜‘\”\Ò!Ð!Øˆ
Ø! 6�ˆÝŒ>˜!ÑÔð 	*Ý”
˜1 5Ð)Ñ)Ô)ˆAå
•"Ô)¨1°XÐ
>Ñ
>Ô
>€CØð ?ð ?ˆØˆs�1‰vŒvˆØ—z’z‘|”|ð 	?ð 	?‰GˆAˆtà�qŠyˆy˜Q &˜[˜[Ø 
Ð1˜1˜1°Ð2Ð2Ô2°a¸$±hÑ>Ð2Ð2Ñ2øð	?ð
 Ðr   )NNN)Ú__doc__Ú	functoolsr   Únetworkxr   Ú__all__Ú_dispatchabler   r	   r   r   ú<module>r)      sr   ðØ AÐ Aà Ð Ð Ð Ð Ð à Ð Ð Ð à Ð
!€ð €Ô˜ZÐ(Ñ(Ô(ðMð Mð Mñ )Ô(ðMð Mð Mr   