<commit_before># -*- coding: utf-8 -*-

import numpy as np
from scipy import sparse

from . import Graph  # prevent circular import in Python < 3.5


class ErdosRenyi(Graph):
    r"""Erdos Renyi graph.

    The Erdos Renyi graph is constructed by randomly connecting nodes. Each
    edge is included in the graph with probability p, independently from any
    other edge. All edge weights are equal to 1.

    Parameters
    ----------
    N : int
        Number of nodes (default is 100).
    p : float
        Probability to connect a node with another one.
    connected : bool
        Force the graph to be connected (default is False).
    directed : bool
        Define if the graph is directed (default is False).
    max_iter : int
        Maximum number of trials to connect the graph (default is 10).

    Examples
    --------
    >>> G = graphs.ErdosRenyi()

    """

    def __init__(self, N=100, p=0.1, connected=False, directed=False,
                 max_iter=10, **kwargs):
        self.p = p

        if not 0 < p < 1:
            raise ValueError('Probability p should be in [0, 1].')

        M = int(N * (N-1) if directed else N * (N-1) / 2)
        nb_elem = int(p * M)

        nb_iter = 0
        while True:
            indices = np.random.permutation(M)[:nb_elem]<commit_msg>ErdosRenyi: 0 and 1 are valid probabilities<commit_after># -*- coding: utf-8 -*-

import numpy as np
from scipy import sparse

from . import Graph  # prevent circular import in Python < 3.5


class ErdosRenyi(Graph):
    r"""Erdos Renyi graph.

    The Erdos Renyi graph is constructed by randomly connecting nodes. Each
    edge is included in the graph with probability p, independently from any
    other edge. All edge weights are equal to 1.

    Parameters
    ----------
    N : int
        Number of nodes (default is 100).
    p : float
        Probability to connect a node with another one.
    connected : bool
        Force the graph to be connected (default is False).
    directed : bool
        Define if the graph is directed (default is False).
    max_iter : int
        Maximum number of trials to connect the graph (default is 10).

    Examples
    --------
    >>> G = graphs.ErdosRenyi()

    """

    def __init__(self, N=100, p=0.1, connected=False, directed=False,
                 max_iter=10, **kwargs):
        self.p = p

        if not 0 <= p <= 1:
            raise ValueError('Probability p should be in [0, 1].')

        M = int(N * (N-1) if directed else N * (N-1) / 2)
        nb_elem = int(p * M)

        nb_iter = 0
        while True:
            indices = np.random.permutation(M)[:nb_elem]
{'fraction_non_alphanumeric': 0.09908883826879271, 'fraction_numerical': 0.018982536066818528, 'mean_word_length': 2.046242774566474, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1750998', 'n_tokens_mistral': 825, 'n_tokens_neox': 750, 'n_words': 315}