
    \Mh                     4   d Z ddlZddlmZ g dZ ed           ej        dd          dd                        Z ed           ej        dd          dd	                        Z ed           ej        dd          dd
                        Z	dS )z,
Generators for random intersection graphs.
    N)py_random_state)!uniform_random_intersection_graphk_random_intersection_graph!general_random_intersection_graph   T)graphsreturns_graphc                     ddl m} |                    | |||          }t          j        |t          |                     S )u  Returns a uniform random intersection graph.

    Parameters
    ----------
    n : int
        The number of nodes in the first bipartite set (nodes)
    m : int
        The number of nodes in the second bipartite set (attributes)
    p : float
        Probability of connecting nodes between bipartite sets
    seed : integer, random_state, or None (default)
        Indicator of random number generation state.
        See :ref:`Randomness<randomness>`.

    See Also
    --------
    gnp_random_graph

    References
    ----------
    .. [1] K.B. Singer-Cohen, Random Intersection Graphs, 1995,
       PhD thesis, Johns Hopkins University
    .. [2] Fill, J. A., Scheinerman, E. R., and Singer-Cohen, K. B.,
       Random intersection graphs when m = !(n):
       An equivalence theorem relating the evolution of the g(n, m, p)
       and g(n, p) models. Random Struct. Algorithms 16, 2 (2000), 156–176.
    r   )	bipartite)networkx.algorithmsr   random_graphnxprojected_graphrange)nmpseedr   Gs         `/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/networkx/generators/intersection.pyr   r      sH    < .-----q!Q--Aaq***    c           	      R   t          j        | |z             }t          | | |z             }t          |           D ]L}|                    ||          }|                    t          |gt          |          z  |                     Mt          j        |t          |                     S )a0  Returns a intersection graph with randomly chosen attribute sets for
    each node that are of equal size (k).

    Parameters
    ----------
    n : int
        The number of nodes in the first bipartite set (nodes)
    m : int
        The number of nodes in the second bipartite set (attributes)
    k : float
        Size of attribute set to assign to each node.
    seed : integer, random_state, or None (default)
        Indicator of random number generation state.
        See :ref:`Randomness<randomness>`.

    See Also
    --------
    gnp_random_graph, uniform_random_intersection_graph

    References
    ----------
    .. [1] Godehardt, E., and Jaworski, J.
       Two models of random intersection graphs and their applications.
       Electronic Notes in Discrete Mathematics 10 (2001), 129--132.
    )r   empty_graphr   sampleadd_edges_fromziplenr   )r   r   kr   r   msetvtargetss           r   r   r   3   s    8 	q1uAAE??D1XX ; ;++dA&&	aS3w<</99::::aq***r   c                    t          |          |k    rt          d          t          j        | |z             }t	          | | |z             }t	          |           D ]F}t          ||          D ]3\  }}|                                |k     r|                    ||           4Gt          j        |t	          |                     S )u  Returns a random intersection graph with independent probabilities
    for connections between node and attribute sets.

    Parameters
    ----------
    n : int
        The number of nodes in the first bipartite set (nodes)
    m : int
        The number of nodes in the second bipartite set (attributes)
    p : list of floats of length m
        Probabilities for connecting nodes to each attribute
    seed : integer, random_state, or None (default)
        Indicator of random number generation state.
        See :ref:`Randomness<randomness>`.

    See Also
    --------
    gnp_random_graph, uniform_random_intersection_graph

    References
    ----------
    .. [1] Nikoletseas, S. E., Raptopoulos, C., and Spirakis, P. G.
       The existence and efficient construction of large independent sets
       in general random intersection graphs. In ICALP (2004), J. D´ıaz,
       J. Karhum¨aki, A. Lepist¨o, and D. Sannella, Eds., vol. 3142
       of Lecture Notes in Computer Science, Springer, pp. 1029–1040.
    z(Probability list p must have m elements.)	r   
ValueErrorr   r   r   r   randomadd_edger   )	r   r   r   r   r   r   ur    qs	            r   r   r   W   s    < 1vv{{CDDD
q1uAAE??D1XX ! !aLL 	! 	!DAq{{}}q  

1a   	! aq***r   )N)
__doc__networkxr   networkx.utilsr   __all___dispatchabler   r   r    r   r   <module>r.      s$        * * * * * *   T222+ + + 32 +D T222+ + + 32 +D T222$+ $+ $+ 32 $+ $+ $+r   