maxcut_generator#
- iqm.applications.maxcut.maxcut_generator(n, n_instances, *, graph_family='erdos-renyi', p=0.5, d=3, break_z2=False, seed=1337, enforce_connected=False)[source]#
The generator function for generating random maxcut problem instances.
The generator yields maxcut problem instances using random graphs, created according to the input parameters. If
enforce_connected
is set toTrue
, then the resulting graphs are checked for connectivity and regenerated if the check fails. In that case, the output graphs are not strictly speaking Erdős–Rényi or uniformly random regular graphs anymore.- Parameters:
n (int) – The number of nodes of the graph.
n_instances (int) – The number of maxcut instances to generate.
graph_family (str) – A string describing the random graph family to generate. Possible graph families include ‘erdos-renyi’ and ‘regular’.
p (float) – For the Erdős–Rényi graph, this is the edge probability. For other graph families, it’s ignored.
d (int) – For the random regular graph, this is the degree of each node in the graph. For other graph families, it’s ignored.
break_z2 (bool) – Optional bool indicating whether the \(\mathbb{Z}_2\) symmetry should be explicitly broken in the problem instances.
seed (int) – Optional random seed for generating the problem instances.
enforce_connected (bool) – A bool stating whether it is required that the random graphs are connected.
- Yields:
Problem instances of
MaxCutInstance
randomly constructed in accordance to the input parameters.- Return type: