§
    bŠtj…  ã                   óø   — d Z ddlZddlmZ ddlmZ g d¢Z ed¦  «        ej        d„ ¦   «         ¦   «         Z	 ed¦  «        ej        d	„ ¦   «         ¦   «         Z
 ed¦  «        ej        d
„ ¦   «         ¦   «         ZdS )zDProvides functions for computing the efficiency of nodes and graphs.é    N)ÚNetworkXNoPathé   )Únot_implemented_for)Ú
efficiencyÚlocal_efficiencyÚglobal_efficiencyÚdirectedc                 ó`   — 	 dt          j        | ||¦  «        z  }n# t          $ r d}Y nw xY w|S )ad  Returns the efficiency of a pair of nodes in a graph.

    The *efficiency* of a pair of nodes is the multiplicative inverse of the
    shortest path distance between the nodes [1]_. Returns 0 if no path
    between nodes.

    Parameters
    ----------
    G : :class:`networkx.Graph`
        An undirected graph for which to compute the average local efficiency.
    u, v : node
        Nodes in the graph ``G``.

    Returns
    -------
    float
        Multiplicative inverse of the shortest path distance between the nodes.

    Examples
    --------
    >>> G = nx.Graph([(0, 1), (0, 2), (0, 3), (1, 2), (1, 3)])
    >>> nx.efficiency(G, 2, 3)  # this gives efficiency for node 2 and 3
    0.5

    Notes
    -----
    Edge weights are ignored when computing the shortest path distances.

    See also
    --------
    local_efficiency
    global_efficiency

    References
    ----------
    .. [1] Latora, Vito, and Massimo Marchiori.
           "Efficient behavior of small-world networks."
           *Physical Review Letters* 87.19 (2001): 198701.
           <https://doi.org/10.1103/PhysRevLett.87.198701>

    é   r   )ÚnxÚshortest_path_lengthr   )ÚGÚuÚvÚeffs       úe/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/networkx/algorithms/efficiency_measures.pyr   r      sL   € ðXØ•"Ô)¨!¨Q°Ñ2Ô2Ñ2ˆˆøÝð ð ð Øˆˆˆðøøøà€Js   ‚ œ+ª+c                 óÜ   — t          | ¦  «        }||dz
  z  }|dk    rLt          j        | ¦  «        }d}|D ]-\  }}|                     ¦   «         D ]\  }}|dk    r|d|z  z  }ŒŒ.||z  }nd}|S )a3  Returns the average global efficiency of the graph.

    The *efficiency* of a pair of nodes in a graph is the multiplicative
    inverse of the shortest path distance between the nodes. The *average
    global efficiency* of a graph is the average efficiency of all pairs of
    nodes [1]_.

    Parameters
    ----------
    G : :class:`networkx.Graph`
        An undirected graph for which to compute the average global efficiency.

    Returns
    -------
    float
        The average global efficiency of the graph.

    Examples
    --------
    >>> G = nx.Graph([(0, 1), (0, 2), (0, 3), (1, 2), (1, 3)])
    >>> round(nx.global_efficiency(G), 12)
    0.916666666667

    Notes
    -----
    Edge weights are ignored when computing the shortest path distances.

    See also
    --------
    local_efficiency

    References
    ----------
    .. [1] Latora, Vito, and Massimo Marchiori.
           "Efficient behavior of small-world networks."
           *Physical Review Letters* 87.19 (2001): 198701.
           <https://doi.org/10.1103/PhysRevLett.87.198701>

    r   r   )Úlenr   Úall_pairs_shortest_path_lengthÚitems)	r   ÚnÚdenomÚlengthsÚg_effÚsourceÚtargetsÚtargetÚdistances	            r   r   r   >   s¢   € õT 	ˆA‰Œ€AØ��Q‘‰K€EØ�‚z€zÝÔ3°AÑ6Ô6ˆØˆØ&ð 	*ð 	*‰OˆF�GØ$+§M¢M¡O¤Oð *ð *Ñ �˜Ø˜a’<�<Ø˜Q ™\Ñ)�Eøð*ð 	�‰ˆˆð ˆð €Ló    c                 ó^   ‡ — ˆ fd„‰ D ¦   «         }t          |¦  «        t          ‰ ¦  «        z  S )a¬  Returns the average local efficiency of the graph.

    The *efficiency* of a pair of nodes in a graph is the multiplicative
    inverse of the shortest path distance between the nodes. The *local
    efficiency* of a node in the graph is the average global efficiency of the
    subgraph induced by the neighbors of the node. The *average local
    efficiency* is the average of the local efficiencies of each node [1]_.

    Parameters
    ----------
    G : :class:`networkx.Graph`
        An undirected graph for which to compute the average local efficiency.

    Returns
    -------
    float
        The average local efficiency of the graph.

    Examples
    --------
    >>> G = nx.Graph([(0, 1), (0, 2), (0, 3), (1, 2), (1, 3)])
    >>> nx.local_efficiency(G)
    0.9166666666666667

    Notes
    -----
    Edge weights are ignored when computing the shortest path distances.

    See also
    --------
    global_efficiency

    References
    ----------
    .. [1] Latora, Vito, and Massimo Marchiori.
           "Efficient behavior of small-world networks."
           *Physical Review Letters* 87.19 (2001): 198701.
           <https://doi.org/10.1103/PhysRevLett.87.198701>

    c              3   óh   •K  — | ],}t          ‰                     ‰|         ¦  «        ¦  «        V — Œ-d S )N)r   Úsubgraph)Ú.0r   r   s     €r   ú	<genexpr>z#local_efficiency.<locals>.<genexpr>¦   s<   øè è € ÐFÐF¸qÕ(¨¯ª°A°a´DÑ)9Ô)9Ñ:Ô:ÐFÐFÐFÐFÐFÐFr   )Úsumr   )r   Úefficiency_lists   ` r   r   r   {   s9   ø€ ðV GÐFÐFÐFÀAÐFÑFÔF€OÝˆÑÔ¥# a¡&¤&Ñ(Ð(r   )Ú__doc__Únetworkxr   Únetworkx.exceptionr   Úutilsr   Ú__all__Ú_dispatchabler   r   r   © r   r   ú<module>r.      sñ   ðØ JÐ Jà Ð Ð Ð Ø -Ð -Ð -Ð -Ð -Ð -à 'Ð 'Ð 'Ð 'Ð 'Ð 'à
AÐ
AÐ
A€ð Ð�ZÑ Ô ØÔð.ð .ñ Ôñ !Ô ð.ðb Ð�ZÑ Ô ØÔð8ð 8ñ Ôñ !Ô ð8ðv Ð�ZÑ Ô ØÔð*)ð *)ñ Ôñ !Ô ð*)ð *)ð *)r   