qgym.generators.graph module

This module contains graph generators for InitialMapping.

class qgym.generators.graph.BasicGraphGenerator(interaction_graph_edge_probability=0.5, seed=None)[source]

Bases: GraphGenerator

BasicGraphGenerator is a simple graph generation implementation.

It uses fast_gnp_random_graph() to generate graphs.

__init__(interaction_graph_edge_probability=0.5, seed=None)[source]

Init of the BasicGraphGenerator.

Parameters:
__next__()[source]

Create a new randomly generated :class:~`networkx.Graph`.

Return type:

Graph

__repr__()[source]

String representation of the BasicGraphGenerator.

Return type:

str

set_state_attributes(*, connection_graph=None, **kwargs)[source]

Set the n_qubits attribute.

Parameters:
  • connection_graph (Graph | None) – A Graph representation of the connection graph.

  • kwargs (Any) – Additional keyword arguments. These are not used

Return type:

None

class qgym.generators.graph.GraphGenerator[source]

Bases: Iterator[Graph]

Abstract Base Class for graph generation.

All graph generators should inherit from GraphGenerator to be compatible with the InitialMapping environment.

abstract __next__()[source]

Make a new :class:~`networkx.Graph`, representing an interaction graph.

The __next__ method of a GraphGenerator should generate a :class:~`networkx.Graph` representation of the interaction graph. To be a valid interaction graph, all nodes should have integer labels starting from 0 and up to the number of nodes minus 1.

Return type:

Graph

finite: bool

Boolean value stating whether the generator is finite.

abstract set_state_attributes(**kwargs)[source]

Set attributes that the state can receive.

This method is called inside the mapping environment to receive information about the state. The same keywords as for the the init of the InitialMappingState are provided.

Return type:

None

class qgym.generators.graph.NullGraphGenerator[source]

Bases: GraphGenerator

Generator class for generating empty Graphs.

Useful for unit testing.

__init__()[source]

Init of the NullGraphGenerator

__next__()[source]

Create a new null graph.

Return type:

Graph

__repr__()[source]

String representation of the NullGraphGenerator.

Return type:

str

set_state_attributes(**kwargs)[source]

Receive state attributes, but do nothing with it.

Parameters:

kwargs (Any) – Keyword arguments.

Return type:

None