
    \Mhw                         d Z ddlZg dZ ej        d          dd            Z ej        d          dd            Z ej        d          dd            Zej        d	             Zej        dd
            Z	dS )z 
Eigenvalue spectrum of graphs.
    N)laplacian_spectrumadjacency_spectrummodularity_spectrumnormalized_laplacian_spectrumbethe_hessian_spectrumweight)
edge_attrsc                     ddl }|j                            t          j        | |                                                    S )a  Returns eigenvalues of the Laplacian of G

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

    weight : string or None, optional (default='weight')
       The edge data key used to compute each value in the matrix.
       If None, then each edge has weight 1.

    Returns
    -------
    evals : NumPy array
      Eigenvalues

    Notes
    -----
    For MultiGraph/MultiDiGraph, the edges weights are summed.
    See :func:`~networkx.convert_matrix.to_numpy_array` for other options.

    See Also
    --------
    laplacian_matrix

    Examples
    --------
    The multiplicity of 0 as an eigenvalue of the laplacian matrix is equal
    to the number of connected components of G.

    >>> G = nx.Graph()  # Create a graph with 5 nodes and 3 connected components
    >>> G.add_nodes_from(range(5))
    >>> G.add_edges_from([(0, 2), (3, 4)])
    >>> nx.laplacian_spectrum(G)
    array([0., 0., 0., 2., 2.])

    r   Nr   )scipylinalgeigvalshnxlaplacian_matrixtodenseGr   sps      X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/networkx/linalg/spectrum.pyr   r      sC    N 9b1!FCCCKKMMNNN    c                     ddl }|j                            t          j        | |                                                    S )a#  Return eigenvalues of the normalized Laplacian of G

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

    weight : string or None, optional (default='weight')
       The edge data key used to compute each value in the matrix.
       If None, then each edge has weight 1.

    Returns
    -------
    evals : NumPy array
      Eigenvalues

    Notes
    -----
    For MultiGraph/MultiDiGraph, the edges weights are summed.
    See to_numpy_array for other options.

    See Also
    --------
    normalized_laplacian_matrix
    r   Nr   )r   r   r   r   normalized_laplacian_matrixr   r   s      r   r   r   <   sI    6 9
&q888@@BB  r   c                     ddl }|j                            t          j        | |                                                    S )a  Returns eigenvalues of the adjacency matrix of G.

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

    weight : string or None, optional (default='weight')
       The edge data key used to compute each value in the matrix.
       If None, then each edge has weight 1.

    Returns
    -------
    evals : NumPy array
      Eigenvalues

    Notes
    -----
    For MultiGraph/MultiDiGraph, the edges weights are summed.
    See to_numpy_array for other options.

    See Also
    --------
    adjacency_matrix
    r   Nr   )r   r   eigvalsr   adjacency_matrixr   r   s      r   r   r   ^   sB    6 9R06BBBJJLLMMMr   c                     ddl }|                                 r,|j                            t	          j        |                     S |j                            t	          j        |                     S )a  Returns eigenvalues of the modularity matrix of G.

    Parameters
    ----------
    G : Graph
       A NetworkX Graph or DiGraph

    Returns
    -------
    evals : NumPy array
      Eigenvalues

    See Also
    --------
    modularity_matrix

    References
    ----------
    .. [1] M. E. J. Newman, "Modularity and community structure in networks",
       Proc. Natl. Acad. Sci. USA, vol. 103, pp. 8577-8582, 2006.
    r   N)r   is_directedr   r   r   directed_modularity_matrixmodularity_matrix)r   r   s     r   r   r   ~   sb    . }} :y  !>q!A!ABBBy  !5a!8!8999r   c                     ddl }|j                            t          j        | |                                                    S )u  Returns eigenvalues of the Bethe Hessian matrix of G.

    Parameters
    ----------
    G : Graph
       A NetworkX Graph or DiGraph

    r : float
       Regularizer parameter

    Returns
    -------
    evals : NumPy array
      Eigenvalues

    See Also
    --------
    bethe_hessian_matrix

    References
    ----------
    .. [1] A. Saade, F. Krzakala and L. Zdeborová
       "Spectral clustering of graphs with the bethe hessian",
       Advances in Neural Information Processing Systems. 2014.
    r   N)r   r   r   r   bethe_hessian_matrixr   )r   rr   s      r   r   r      s?    6 9b5a;;CCEEFFFr   r   )N)
__doc__networkxr   __all___dispatchabler   r   r   r   r    r   r   <module>r(      s          X&&&(O (O (O '&(OV X&&&   '&B X&&&N N N '&N> : : :< G G G G G Gr   