§
    bŠtjÁ  ã                   óî   — d Z ddlZddlmZ ddgZ ed¦  «         ed¦  «        ej        d„ ¦   «         ¦   «         ¦   «         Z ed¦  «         ed¦  «        ej        d	„ ¦   «         ¦   «         ¦   «         ZdS )
z
Communicability.
é    N)Únot_implemented_forÚcommunicabilityÚcommunicability_expÚdirectedÚ
multigraphc           
      óP  — ddl }t          | ¦  «        }t          j        | |¦  «        }d||dk    <   |j                             |¦  «        \  }}|                     |¦  «        }t          t          |t          t          |¦  «        ¦  «        ¦  «        ¦  «        }i }| D ]†}	i ||	<   | D ]|}
d}||	         }||
         }t          t          |¦  «        ¦  «        D ]3}||dd…|f         |         |dd…|f         |         z  ||         z  z  }Œ4t          |¦  «        ||	         |
<   Œ}Œ‡|S )a—  Returns communicability between all pairs of nodes in G.

    The communicability between pairs of nodes in G is the sum of
    walks of different lengths starting at node u and ending at node v.

    Parameters
    ----------
    G: graph

    Returns
    -------
    comm: dictionary of dictionaries
        Dictionary of dictionaries keyed by nodes with communicability
        as the value.

    Raises
    ------
    NetworkXError
       If the graph is not undirected and simple.

    See Also
    --------
    communicability_exp:
       Communicability between all pairs of nodes in G  using spectral
       decomposition.
    communicability_betweenness_centrality:
       Communicability betweenness centrality for each node in G.

    Notes
    -----
    This algorithm uses a spectral decomposition of the adjacency matrix.
    Let G=(V,E) be a simple undirected graph.  Using the connection between
    the powers  of the adjacency matrix and the number of walks in the graph,
    the communicability  between nodes `u` and `v` based on the graph spectrum
    is [1]_

    .. math::
        C(u,v)=\sum_{j=1}^{n}\phi_{j}(u)\phi_{j}(v)e^{\lambda_{j}},

    where `\phi_{j}(u)` is the `u\rm{th}` element of the `j\rm{th}` orthonormal
    eigenvector of the adjacency matrix associated with the eigenvalue
    `\lambda_{j}`.

    References
    ----------
    .. [1] Ernesto Estrada, Naomichi Hatano,
       "Communicability in complex networks",
       Phys. Rev. E 77, 036111 (2008).
       https://arxiv.org/abs/0707.0756

    Examples
    --------
    >>> G = nx.Graph([(0, 1), (1, 2), (1, 5), (5, 4), (2, 4), (2, 3), (4, 3), (3, 6)])
    >>> c = nx.communicability(G)
    r   Né   ç        )ÚnumpyÚlistÚnxÚto_numpy_arrayÚlinalgÚeighÚexpÚdictÚzipÚrangeÚlenÚfloat)ÚGÚnpÚnodelistÚAÚwÚvecÚexpwÚmappingÚcÚuÚvÚsÚpÚqÚjs                  úe/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/networkx/algorithms/communicability_alg.pyr   r      sA  € ðv ÐÐÐå�A‰wŒw€HÝ
Ô˜!˜XÑ&Ô&€Aà€A€aˆ3‚h�KØŒY�^Š^˜AÑÔ�F€A€sØ�6Š6�!‰9Œ9€DÝ•3�x¥¥s¨8¡}¤}Ñ!5Ô!5Ñ6Ô6Ñ7Ô7€GØ
€Aàð ð ˆØˆˆ!‰Øð 	ð 	ˆAØˆAØ˜”
ˆAØ˜”
ˆAÝ�3˜x™=œ=Ñ)Ô)ð ;ð ;�Ø�S˜˜˜˜A˜”Y˜q”\ C¨¨¨¨1¨¤I¨a¤LÑ0°4¸´7Ñ:Ñ:��Ý˜A‘h”hˆAˆaŒD�‰GˆGð	ð €Hó    c           
      ó„  — ddl }t          | ¦  «        }t          j        | |¦  «        }d||dk    <   |j                             |¦  «        }t          t          |t          t          |¦  «        ¦  «        ¦  «        ¦  «        }i }| D ]8}i ||<   | D ].}t          |||         ||         f         ¦  «        ||         |<   Œ/Œ9|S )a¬  Returns communicability between all pairs of nodes in G.

    Communicability between pair of node (u,v) of node in G is the sum of
    walks of different lengths starting at node u and ending at node v.

    Parameters
    ----------
    G: graph

    Returns
    -------
    comm: dictionary of dictionaries
        Dictionary of dictionaries keyed by nodes with communicability
        as the value.

    Raises
    ------
    NetworkXError
        If the graph is not undirected and simple.

    See Also
    --------
    communicability:
       Communicability between pairs of nodes in G.
    communicability_betweenness_centrality:
       Communicability betweenness centrality for each node in G.

    Notes
    -----
    This algorithm uses matrix exponentiation of the adjacency matrix.

    Let G=(V,E) be a simple undirected graph.  Using the connection between
    the powers  of the adjacency matrix and the number of walks in the graph,
    the communicability between nodes u and v is [1]_,

    .. math::
        C(u,v) = (e^A)_{uv},

    where `A` is the adjacency matrix of G.

    References
    ----------
    .. [1] Ernesto Estrada, Naomichi Hatano,
       "Communicability in complex networks",
       Phys. Rev. E 77, 036111 (2008).
       https://arxiv.org/abs/0707.0756

    Examples
    --------
    >>> G = nx.Graph([(0, 1), (1, 2), (1, 5), (5, 4), (2, 4), (2, 3), (4, 3), (3, 6)])
    >>> c = nx.communicability_exp(G)
    r   Nr	   r
   )Úscipyr   r   r   r   Úexpmr   r   r   r   r   )	r   Úspr   r   ÚexpAr   r   r    r!   s	            r&   r   r   ]   sÒ   € ðp ÐÐÐå�A‰wŒw€HÝ
Ô˜!˜XÑ&Ô&€Aà€A€aˆ3‚h�KàŒ9�>Š>˜!ÑÔ€DÝ•3�x¥¥s¨8¡}¤}Ñ!5Ô!5Ñ6Ô6Ñ7Ô7€GØ
€AØð :ð :ˆØˆˆ!‰Øð 	:ð 	:ˆAÝ˜D ¨¤¨W°Q¬ZÐ!7Ô8Ñ9Ô9ˆAˆaŒD�‰GˆGð	:à€Hr'   )	Ú__doc__Únetworkxr   Únetworkx.utilsr   Ú__all__Ú_dispatchabler   r   © r'   r&   ú<module>r3      sã   ððð ð Ð Ð Ð Ø .Ð .Ð .Ð .Ð .Ð .àÐ3Ð
4€ð Ð�ZÑ Ô ØÐ�\Ñ"Ô"ØÔðLð Lñ Ôñ #Ô"ñ !Ô ðLð^ Ð�ZÑ Ô ØÐ�\Ñ"Ô"ØÔðCð Cñ Ôñ #Ô"ñ !Ô ðCð Cð Cr'   