ó ŸÃÒYc@sqdZddlZddlZddlmZdjdgƒZdddgZdd „Z d „Z d „Z dS( s, Generators for random intersection graphs. iÿÿÿÿN(t bipartites sAric Hagberg (hagberg@lanl.gov)t!uniform_random_intersection_graphtk_random_intersection_grapht!general_random_intersection_graphcCs1tj|||d|ƒ}tj|t|ƒƒS(sPReturn 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 : int, optional Seed for random number generator (default=None). 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. tseed(Rt random_graphtnxtprojected_graphtrange(tntmtpRtG((sv/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/generators/intersection.pyRscCsˆtj||ƒ}t|||ƒ}xIt|ƒD];}tj||ƒ}|jt|gt|ƒ|ƒƒq3Wtj|t|ƒƒS(síReturn 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 : int, optional Seed for random number generator (default=None). 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. ( Rt empty_graphRtrandomtsampletadd_edges_fromtziptlenR(R R tkR tmsettvttargets((sv/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/generators/intersection.pyR6s 'cCs¹t|ƒ|kr!tdƒ‚ntj||ƒ}t|||ƒ}xYt|ƒD]K}xBt||ƒD]1\}}tjƒ|krj|j||ƒqjqjWqTWtj|t|ƒƒS(sÁReturn 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 : int, optional Seed for random number generator (default=None). 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. s(Probability list p must have m elements.( Rt ValueErrorRR RRRtadd_edgeR(R R R R RtuRtq((sv/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/generators/intersection.pyRWs( t__doc__RtnetworkxRtnetworkx.algorithmsRtjoint __author__t__all__tNoneRRR(((sv/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/generators/intersection.pyts     !