dimod.generators.gnp_random_bqm

gnp_random_bqm(n: Union[int, Sequence[Hashable]], p: float, vartype: Union[dimod.vartypes.Vartype, str, frozenset], cls: None = None, random_state: Optional[Union[numpy.random.mtrand.RandomState, int]] = None, bias_generator: Optional[Callable[[int], Sequence[Union[float, numpy.floating, numpy.integer]]]] = None) dimod.binary.binary_quadratic_model.BinaryQuadraticModel[source]

Generate a BQM structured as an Erdős-Rényi graph.

Parameters
  • n – Variables labels. If an int, variables are labelled [0, variables ).

  • p – Probability for interaction creation.

  • vartype

    Variable type for the BQM. Accepted input values:

  • cls – Deprecated. Does nothing.

  • random_state – Random seed or a random state generator. Used for generating the structure of the BQM and, if bias_generator is not given, for the bias generation.

  • bias_generator – Bias generating function. Should accept a single argument n and return an ndarray of biases of length n. May be called multiple times. If not provided, uniform() is used by default.

Returns

A binary quadratic model.

Notes

This algorithm runs in O(n^2) time and space.

Deprecated since version 0.10.13: The cls keyword argument will be removed in 0.12.0. It currently does nothing.