+
    �°³jÑ	  ã                   óx   € R t ^ RIt^ RIHt R.t]! R4      ]! R4      ]P                  RR l4       4       4       tR# )z5Bethe Hessian or deformed Laplacian matrix of graphs.N)Únot_implemented_forÚbethe_hessian_matrixÚdirectedÚ
multigraphc                ó8  € ^ RI pVf   \        V 4      pVfY   \        R \        P                  ! V 4       4       4      \        R \        P                  ! V 4       4       4      ,          ^,
          p\        P
                  ! WRR7      pVP                  w  rVVP                  P                  VP                  ^R7      ^ 3We3R7      P                  4       pVP                  P                  WeRR7      pV^,          ^,
          V,          W,          ,
          V,           # )	u8  Returns the Bethe Hessian matrix of G.

The Bethe Hessian is a family of matrices parametrized by r, defined as
H(r) = (r^2 - 1) I - r A + D where A is the adjacency matrix, D is the
diagonal matrix of node degrees, and I is the identify matrix. It is equal
to the graph laplacian when the regularizer r = 1.

The default choice of regularizer should be the ratio [2]_

.. math::
  r_m = \left(\sum k_i \right)^{-1}\left(\sum k_i^2 \right) - 1

Parameters
----------
G : Graph
   A NetworkX graph
r : float
   Regularizer parameter
nodelist : list, optional
   The rows and columns are ordered according to the nodes in nodelist.
   If nodelist is None, then the ordering is produced by ``G.nodes()``.

Returns
-------
H : scipy.sparse.csr_array
  The Bethe Hessian matrix of `G`, with parameter `r`.

Examples
--------
>>> k = [3, 2, 2, 1, 0]
>>> G = nx.havel_hakimi_graph(k)
>>> H = nx.bethe_hessian_matrix(G)
>>> H.toarray()
array([[ 3.5625, -1.25  , -1.25  , -1.25  ,  0.    ],
       [-1.25  ,  2.5625, -1.25  ,  0.    ,  0.    ],
       [-1.25  , -1.25  ,  2.5625,  0.    ,  0.    ],
       [-1.25  ,  0.    ,  0.    ,  1.5625,  0.    ],
       [ 0.    ,  0.    ,  0.    ,  0.    ,  0.5625]])

See Also
--------
bethe_hessian_spectrum
adjacency_matrix
laplacian_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.
.. [2] C. M. Le, E. Levina
   "Estimating the number of communities in networks by spectral methods"
   arXiv:1507.00827, 2015.
Nc              3   ó8   "  € T F  w  rV^,          x € K  	  R# 5i)é   N© ©Ú.0ÚvÚds   &  Úc/home/luca/screen-checking/.venv/lib/python3.14/site-packages/networkx/linalg/bethehessianmatrix.pyÚ	<genexpr>Ú'bethe_hessian_matrix.<locals>.<genexpr>H   s   é € Ð.¡™˜��1—’£ùs   ‚c              3   ó*   "  € T F	  w  rVx € K  	  R # 5i)Nr	   r
   s   &  r   r   r   H   s   é € Ð4PÁ<¹4¸1µQÃ<ùs   ‚Úcsr)ÚnodelistÚformat)Úaxis)Úshape)r   )ÚscipyÚlistÚsumÚnxÚdegreeÚto_scipy_sparse_arrayr   ÚsparseÚ	dia_arrayÚtocsrÚ	eye_array)	ÚGÚrr   ÚspÚAÚnÚmÚDÚIs	   &&&      r   r   r   	   sÙ   € ót àÒÜ˜“7ˆØ‚yÜÑ.¤§¢¨1¤Ó.Ó.´Ñ4PÄ2Ç9Â9ÈQÄ<Ó4PÓ1PÕPÐSTÕTˆÜ
× Ò  ¸eÔD€AØ�7‰7�D€AØ
�	‰	×Ñ˜QŸU™U¨˜U›]¨AÐ.°q°fÐÓ=×CÑCÓE€AØ
�	‰	×Ñ˜A¨ÐÓ/€AØˆq�D�1�H˜�>˜A�EÕ! AÕ%Ð%ó    )NN)Ú__doc__Únetworkxr   Únetworkx.utilsr   Ú__all__Ú_dispatchabler   r	   r)   r   Ú<module>r/      sL   ðÙ ;ã Ý .à!Ð
"€ñ �ZÓ Ù�\Ó"Ø×ÑóA&ó ó #ó !òA&r)   