qml.qaoa.cycle.wires_to_edges

wires_to_edges(graph)[source]

Maps the wires of a register of qubits to corresponding edges.

Example

>>> g = nx.complete_graph(4).to_directed()
>>> wires_to_edges(g)
{0: (0, 1),
 1: (0, 2),
 2: (0, 3),
 3: (1, 0),
 4: (1, 2),
 5: (1, 3),
 6: (2, 0),
 7: (2, 1),
 8: (2, 3),
 9: (3, 0),
 10: (3, 1),
 11: (3, 2)}
>>> g = rx.generators.directed_mesh_graph(4, [0,1,2,3])
>>> wires_to_edges(g)
{0: (0, 1),
 1: (0, 2),
 2: (0, 3),
 3: (1, 0),
 4: (1, 2),
 5: (1, 3),
 6: (2, 0),
 7: (2, 1),
 8: (2, 3),
 9: (3, 0),
 10: (3, 1),
 11: (3, 2)}
Parameters

graph (nx.Graph or rx.PyGraph or rx.PyDiGraph) – the graph specifying possible edges

Returns

a mapping from wires to graph edges

Return type

Dict[Tuple, int]