
    \Mhn                     N    d Z ddlZdgZ ej        d          dd            ZdS )z
Spectral bipartivity measure.
    Nspectral_bipartivityweight)
edge_attrsc           
      x   ddl }t          |           }t          j        | ||          }|j                            |          }|j                            |           }d||z   z  }|Zt          |                                                                |                                                                z            S t          t          |t          t          |                                        }	i }
|D ]:}|	|         }|                    ||          |                    ||          z  |
|<   ;|
S )u9  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                f/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/networkx/algorithms/bipartite/spectral.pyr   r   
   s   T AwwH
!Xf555A9>>!DINNA2E4%< E}U^^%%))++dmmoo.A.A.C.CCDDD S5X#7#78899 	7 	7AaAJJq!$$tyyA6BqEE	    )Nr   )__doc__networkxr	   __all___dispatchabler    r"   r!   <module>r(      s`        !
" X&&&: : : '&: : :r"   