dimod.generators.gnp_random_bqm#

gnp_random_bqm(n: int | Sequence[Hashable], p: float, vartype: Vartype | str | frozenset, cls: None = None, random_state: RandomState | int | None = None, bias_generator: Callable[[int], Sequence[float | floating | integer]] | None = None) 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.