Utilities#

Decorators#

Decorators allow for input checking and default parameter setting for algorithms.

binary_quadratic_model_sampler(which_args)

Decorator to validate sampler arguments.

Graph Indexing#

See the Coordinates Conversion subsection on instantiating the needed lattice size and setting correct domain and range for coordinates in a QPU working graph. For the iterator versions of these functions, see the code.

Chimera#

chimera_coordinates.chimera_to_linear(q)

Converts a 4-term Chimera coordinate to a linear index.

chimera_coordinates.graph_to_chimera(g)

Returns a copy of the graph g relabeled to have Chimera coordinates.

chimera_coordinates.graph_to_linear(g)

Returns a copy of the graph g relabeled to have linear indices.

chimera_coordinates.linear_to_chimera(r)

Converts a linear index to a 4-term Chimera coordinate.

chimera_sublattice_mappings(source, target)

Yields mappings from a Chimera graph into a larger Chimera graph.

find_chimera_indices(G)

Determines the Chimera indices of the nodes in graph G.

Pegasus#

pegasus_coordinates.graph_to_linear(g)

Returns a copy of the graph g relabeled to have linear indices.

pegasus_coordinates.graph_to_nice(g)

Returns a copy of the graph g relabeled to have nice coordinates.

pegasus_coordinates.graph_to_pegasus(g)

Returns a copy of the graph g relabeled to have Pegasus coordinates.

pegasus_coordinates.linear_to_nice(r)

Converts a linear index into a 5-term nice coordinate.

pegasus_coordinates.linear_to_pegasus(r)

Converts a linear index into a 4-term Pegasus coordinate.

pegasus_coordinates.nice_to_linear(n)

Converts a 5-term nice coordinate into a linear index.

pegasus_coordinates.nice_to_pegasus(n)

Converts a 5-term nice coordinate into a 4-term Pegasus coordinate.

pegasus_coordinates.pegasus_to_linear(q)

Converts a 4-term Pegasus coordinate into a linear index.

pegasus_coordinates.pegasus_to_nice(p)

Converts a 4-term Pegasus coordinate to a 5-term nice coordinate.

pegasus_sublattice_mappings(source, target)

Yields mappings from a Chimera or Pegasus graph into a Pegasus graph.

Zephyr#

zephyr_coordinates.graph_to_linear(g)

Returns a copy of the graph g relabeled to have linear indices.

zephyr_coordinates.graph_to_zephyr(g)

Returns a copy of the graph g relabeled to have Zephyr coordinates.

zephyr_coordinates.linear_to_zephyr(r)

Converts a linear index into a 5-term Zephyr coordinate.

zephyr_coordinates.zephyr_to_linear(q)

Converts a 5-term Zephyr coordinate into a linear index.

zephyr_sublattice_mappings(source, target[, ...])

Yields mappings from a Chimera or Zephyr graph into a Zephyr graph.

Coordinates Conversion#

class chimera_coordinates(m, n=None, t=None)[source]#

Provides coordinate converters for the chimera indexing scheme.

Parameters:
  • m (int) – The number of rows in the Chimera lattice.

  • n (int, optional (default m)) – The number of columns in the Chimera lattice.

  • t (int, optional (default 4)) – The size of the shore within each Chimera tile.

Examples

Convert between Chimera coordinates and linear indices directly

>>> coords = dnx.chimera_coordinates(16, 16, 4)
>>> coords.chimera_to_linear((0, 2, 0, 1))
17
>>> coords.linear_to_chimera(17)
(0, 2, 0, 1)

Construct a new graph with the coordinate labels

>>> C16 = dnx.chimera_graph(16)
>>> coords = dnx.chimera_coordinates(16)
>>> G = nx.Graph()
>>> G.add_nodes_from(coords.iter_linear_to_chimera(C16.nodes))
>>> G.add_edges_from(coords.iter_linear_to_chimera_pairs(C16.edges))

See also

chimera_graph()

Describes the various conventions.

class pegasus_coordinates(m)[source]#

Provides coordinate converters for the Pegasus indexing schemes.

Parameters:

m (int) – Size parameter for the Pegasus lattice.

See also

pegasus_graph()

Describes the various coordinate conventions.

class zephyr_coordinates(m, t=4)[source]#

Provides coordinate converters for the Zephyr indexing schemes.

Parameters:
  • m (int) – Grid parameter for the Zephyr lattice.

  • t (int) – Tile parameter for the Zephyr lattice; must be even.

See also

zephyr_graph()

Describes the various coordinate conventions.

Exceptions#

Base exceptions and errors for D-Wave NetworkX.

All exceptions are derived from NetworkXException.

DWaveNetworkXException

Base class for exceptions in DWaveNetworkX.

DWaveNetworkXMissingSampler

Exception raised by an algorithm requiring a discrete model sampler when none is provided.