Ë
    D^(hü  ã                   óŠ   — d Z ddlZddlZddlmZ dgZ ed«       ed«       ej                  d¬«      d
d	„«       «       «       Zy)z#Computation of graph non-randomnessé    N)Únot_implemented_forÚnon_randomnessÚdirectedÚ
multigraphÚweight)Ú
edge_attrsc           	      ó  — ddl }t        j                  | «      rt        j                  d«      ‚t        j                  | «      st        j
                  d«      ‚t        t        t        j                  | «      «      «      dkD  rt        j                  d«      ‚|€1t        t        t        j                  j                  | «      «      «      }|j                  j                  t        j                  | |¬«      «      }t        |j!                  |j#                  |d| «      «      «      }| j%                  «       }| j'                  «       }d|z  |z  |||z
  z  z  }||d|z  z
  |z  |z   z
  t)        j*                  d|z  |z  d|z
  z  «      z  }	||	fS )	a›  Compute the non-randomness of graph G.

    The first returned value nr is the sum of non-randomness values of all
    edges within the graph (where the non-randomness of an edge tends to be
    small when the two nodes linked by that edge are from two different
    communities).

    The second computed value nr_rd is a relative measure that indicates
    to what extent graph G is different from random graphs in terms
    of probability. When it is close to 0, the graph tends to be more
    likely generated by an Erdos Renyi model.

    Parameters
    ----------
    G : NetworkX graph
        Graph must be symmetric, connected, and without self-loops.

    k : int
        The number of communities in G.
        If k is not set, the function will use a default community
        detection algorithm to set it.

    weight : string or None, optional (default=None)
        The name of an edge attribute that holds the numerical value used
        as a weight. If None, then each edge has weight 1, i.e., the graph is
        binary.

    Returns
    -------
    non-randomness : (float, float) tuple
        Non-randomness, Relative non-randomness w.r.t.
        Erdos Renyi random graphs.

    Raises
    ------
    NetworkXException
        if the input graph is not connected.
    NetworkXError
        if the input graph contains self-loops or if graph has no edges.

    Examples
    --------
    >>> G = nx.karate_club_graph()
    >>> nr, nr_rd = nx.non_randomness(G, 2)
    >>> nr, nr_rd = nx.non_randomness(G, 2, "weight")

    Notes
    -----
    This computes Eq. (4.4) and (4.5) in Ref. [1]_.

    If a weight field is passed, this algorithm will use the eigenvalues
    of the weighted adjacency matrix to compute Eq. (4.4) and (4.5).

    References
    ----------
    .. [1] Xiaowei Ying and Xintao Wu,
           On Randomness Measures for Social Networks,
           SIAM International Conference on Data Mining. 2009
    r   Nz-non_randomness not applicable to empty graphszNon connected graph.z!Graph must not contain self-loops)r   é   é   )ÚnumpyÚnxÚis_emptyÚNetworkXErrorÚis_connectedÚNetworkXExceptionÚlenÚlistÚselfloop_edgesÚtupleÚ	communityÚlabel_propagation_communitiesÚlinalgÚeigvalsÚto_numpy_arrayÚfloatÚrealÚsumÚnumber_of_nodesÚnumber_of_edgesÚmathÚsqrt)
ÚGÚkr   ÚnpÚeigenvaluesÚnrÚnÚmÚpÚnr_rds
             ú`/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/networkx/algorithms/non_randomness.pyr   r      sX  € ó~ ô 
‡{�{�1„~Ü×ÑÐNÓOÐOÜ�?‰?˜1ÔÜ×"Ñ"Ð#9Ó:Ð:Ü
Œ4”×!Ñ! !Ó$Ó%Ó&¨Ò*Ü×ÑÐBÓCÐCà€yÜ””b—l‘l×@Ñ@ÀÓCÓDÓEˆð —)‘)×#Ñ#¤B×$5Ñ$5°aÀÔ$GÓH€KÜ	ˆr�w‰w�r—v‘v˜k¨"¨1˜oÓ.Ó/Ó	0€Bà	×ÑÓ€AØ	×ÑÓ€AØ	
ˆQ‰�‰�q˜A ™E‘{Ñ#€Að �A˜˜A™‘I ‘? QÑ&Ñ'¬4¯9©9°Q¸±U¸Q±YÀ!ÀaÁ%Ñ5HÓ+IÑI€Eàˆuˆ9Ðó    )Nr   )	Ú__doc__r    Únetworkxr   Únetworkx.utilsr   Ú__all__Ú_dispatchabler   © r,   r+   ú<module>r3      sV   ðÙ *ã ã Ý .àÐ
€ñ �ZÓ Ù�\Ó"Ø€×Ñ˜XÔ&òTó 'ó #ó !ñTr,   