K iwdZddlZgdZejdd dZejdd dZejdd dZejd Zejd d Z y) z Eigenvalue spectrum of graphs. N)laplacian_spectrumadjacency_spectrummodularity_spectrumnormalized_laplacian_spectrumbethe_hessian_spectrumweight) edge_attrscddl}|jjtj||j S)aReturns 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.]) rNr)scipylinalgeigvalshnxlaplacian_matrixtodenseGrsps ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/networkx/linalg/spectrum.pyrrs3N 99  b11!FCKKM NNcddl}|jjtj||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 rNr )r r rrnormalized_laplacian_matrixrrs rrr<s76 99   &&q8@@B rcddl}|jjtj||j S)aReturns 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 rNr )r r eigvalsradjacency_matrixrrs rrr^s26 99  R006BJJL MMrcddl}|jr.|jjt j |S|jjt j |S)aReturns 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. rN)r is_directedr rrdirected_modularity_matrixmodularity_matrix)rrs rrr~sP.}}yy  !>!>q!ABByy  !5!5a!899rcddl}|jjtj||j S)uReturns 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. rN)r r rrbethe_hessian_matrixr)rrrs rrrs26 99  b55a;CCE FFrr )N) __doc__networkxr__all__ _dispatchablerrrrrrrr(s X&(O'(OVX&'BX&N'N>::<GGr