<commit_before># -*- coding: utf-8 -*-
"""
Generators for random intersection graphs.
"""
#    Copyright (C) 2011 by 
#    <NAME> <<EMAIL>>
#    <NAME> <<EMAIL>>
#    <NAME> <<EMAIL>>
#    All rights reserved.
#    BSD license.
import random
import networkx as nx
__author__ = "\n".join(['<NAME> (<EMAIL>)'])

__all__ = ['uniform_random_intersection_graph',
           'k_random_intersection_graph',
           'general_random_intersection_graph',
           ]

def uniform_random_intersection_graph(n, m, p, seed=None):
    """Return 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] <NAME>, Random Intersection Graphs, 1995,
       PhD thesis, Johns Hopkins University
    .. [2] <NAME>., <NAME>., and <NAME>., 
       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.
    """
    G=nx.random_graph(n, m, p, seed=seed)
    return nx.projected_graph(G, range(n)) 

def k_random_intersection_graph(n,m,k):
    """Return a intersection graph with randomly chosen attribute sets for
    each node that are of equal size (k). <commit_msg>use bipartite package<commit_after># -*- coding: utf-8 -*-
"""
Generators for random intersection graphs.
"""
#    Copyright (C) 2011 by 
#    <NAME> <<EMAIL>>
#    <NAME> <<EMAIL>>
#    <NAME> <<EMAIL>>
#    All rights reserved.
#    BSD license.
import random
import networkx as nx
from networkx.algorithms import bipartite

__author__ = "\n".join(['<NAME> (<EMAIL>)'])

__all__ = ['uniform_random_intersection_graph',
           'k_random_intersection_graph',
           'general_random_intersection_graph',
           ]

def uniform_random_intersection_graph(n, m, p, seed=None):
    """Return 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] <NAME>, Random Intersection Graphs, 1995,
       PhD thesis, Johns Hopkins University
    .. [2] <NAME>., <NAME>., and <NAME>., 
       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.
    """
    G=bipartite.random_graph(n, m, p, seed=seed)
    return nx.projected_graph(G, range(n)) 

def k_random_intersection_graph(n,m,k):
    """Return a intersection graph with randomly chosen attribute sets for
    each node that are of equal size (k). 
{'fraction_non_alphanumeric': 0.12423312883435583, 'fraction_numerical': 0.014723926380368098, 'mean_word_length': 2.6517357222844344, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6326632', 'n_tokens_mistral': 1030, 'n_tokens_neox': 955, 'n_words': 336}