
    hn                     F    S r SSKrS/r\R                  " SS9SS j5       rg)z
Spectral bipartivity measure.
    Nspectral_bipartivityweight)
edge_attrsc           
         SSK n[        U 5      n[        R                  " XUS9nUR                  R                  U5      nUR                  R                  U* 5      nSXg-   -  nUcF  [        UR                  5       R                  5       UR                  5       R                  5       -  5      $ [        [        U[        [        U5      5      5      5      n	0 n
U H,  nX   nUR                  X5      UR                  X5      -  X'   M.     U
$ )u  Returns the spectral bipartivity.

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

nodes : list or container  optional(default is all nodes)
  Nodes to return value of spectral bipartivity contribution.

weight : string or None  optional (default = 'weight')
  Edge data key to use for edge weights. If None, weights set to 1.

Returns
-------
sb : float or dict
   A single number if the keyword nodes is not specified, or
   a dictionary keyed by node with the spectral bipartivity contribution
   of that node as the value.

Examples
--------
>>> from networkx.algorithms import bipartite
>>> G = nx.path_graph(4)
>>> bipartite.spectral_bipartivity(G)
1.0

Notes
-----
This implementation uses Numpy (dense) matrices which are not efficient
for storing large sparse graphs.

See Also
--------
color

References
----------
.. [1] E. Estrada and J. A. Rodríguez-Velázquez, "Spectral measures of
   bipartivity in complex networks", PhysRev E 72, 046105 (2005)
r   N)r   g      ?)scipylistnxto_numpy_arraylinalgexpmfloatdiagonalsumdictziprangelenitem)Gnodesr   spnodelistAexpAexpmAcoshAindexsbnis                X/var/www/html/env/lib/python3.13/site-packages/networkx/algorithms/bipartite/spectral.pyr   r   
   s    T AwH
!f5A99>>!DIINNA2E4< E}U^^%))+dmmo.A.A.CCDD S5X#789AAJJq$tyy6BE  	    )Nr   )__doc__networkxr	   __all___dispatchabler    r"   r!   <module>r(      s6    !
" X&: ':r"   