Utilities#
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#
Converts a 4-term Chimera coordinate to a linear index. |
|
Returns a copy of the graph |
|
Returns a copy of the graph |
|
Converts a linear index to a 4-term Chimera coordinate. |
|
|
Yields mappings from a Chimera graph into a larger Chimera graph. |
Determines the Chimera indices of the nodes in graph |
Pegasus#
Returns a copy of the graph |
|
Returns a copy of the graph |
|
Returns a copy of the graph |
|
Converts a linear index into a 5-term nice coordinate. |
|
Converts a linear index into a 4-term Pegasus coordinate. |
|
Converts a 5-term nice coordinate into a linear index. |
|
Converts a 5-term nice coordinate into a 4-term Pegasus coordinate. |
|
Converts a 4-term Pegasus coordinate into a linear index. |
|
Converts a 4-term Pegasus coordinate to a 5-term nice coordinate. |
|
|
Yields mappings from a Chimera or Pegasus graph into a Pegasus graph. |
Zephyr#
Returns a copy of the graph g relabeled to have linear indices. |
|
Returns a copy of the graph g relabeled to have Zephyr coordinates. |
|
Converts a linear index into a 5-term Zephyr coordinate. |
|
Converts a 5-term Zephyr coordinate into a linear index. |
|
|
Yields mappings from a Chimera or Zephyr graph into a Zephyr graph. |
Coordinates Conversion#
- class chimera_coordinates(m: int, n: int | None = None, t: int | None = None)[source]#
Provides coordinate converters for the chimera indexing scheme.
- Parameters:
m – The number of rows in the Chimera lattice.
n – The number of columns in the Chimera lattice.
t – The size of the shore within each Chimera tile.
Examples
Convert between Chimera coordinates and linear indices directly
>>> coords = dwave.graphs.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 = dwave.graphs.chimera_graph(16) >>> coords = dwave.graphs.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: int)[source]#
Provides coordinate converters for the Pegasus indexing schemes.
- Parameters:
m – Size parameter for the Pegasus lattice.
See also:
pegasus_graph()describes the various coordinate conventions.
- class zephyr_coordinates(m: int, t: int = 4)[source]#
Provides coordinate converters for the Zephyr indexing schemes.
- Parameters:
m – Grid parameter for the Zephyr lattice.
t – Tile parameter for the Zephyr lattice; must be even.
See also
zephyr_graph()for descriptions the various coordinate conventions.
Exceptions#
Base exceptions and errors for dwave-graphs.
Base exception for dwave-graphs errors. |