K idZddlZddlmZgdZedej ddd dZedej ddd d Zedej ddd d Z y) z, Generators for random intersection graphs. N)py_random_state)!uniform_random_intersection_graphk_random_intersection_graph!general_random_intersection_graphT)graphs returns_graphctddlm}|j||||}tj|t |S)uReturns 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`. 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_graphnxprojected_graphrange)nmpseedr Gs f/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/networkx/generators/intersection.pyrrs4<.q!Q-A  aq **c "tj||z}t|||z}t|D]<}|j||}|j t |gt |z|>tj|t|S)a0Returns 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`. 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_graphrsampleadd_edges_fromziplenr)rrkrrmsetvtargetss rrr3s8 q1uA AE?D 1X;++dA& aS3w</9:;   aq **rcTt||k7r tdtj||z}t |||z}t |D]<}t ||D]+\}}|j |ks|j||->tj|t |S)uReturns 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`. 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 ValueErrorrrrrrandomadd_edger) rrrrrrur qs rrrWs< 1v{CDD q1uA AE?D 1X!aL !DAq{{}q  1a  !!   aq **r)N) __doc__networkxrnetworkx.utilsr__all__ _dispatchablerrrrrr.s* T2+3+DT2+3+DT2$+3$+r