Skip to content

[Named Topologies] Add nodes_to_linequbits method to LineTopology  #4710

@tanujkhattar

Description

@tanujkhattar

Routing utilities currently present in cirq contrib expect a networkx graph of device (/target topology) where each node is a cirq.Qid. NamedTopology stores topology graphs where each node is a number / tuple.
TiltedSquareLattice has a nodes_to_gridqubits method which can provide a mapping from the graph nodes to the corresponding grid qubits.

def nodes_to_gridqubits(self, offset=(0, 0)) -> Dict[Tuple[int, int], 'cirq.GridQubit']:

This can be used to quickly get the graph needed for routing circuits from the topology graph as follows:

routing_graph = nx.relabel_nodes(topology.graph, topology.nodes_to_gridqubits())

A similar convenience method, nodes_to_linequbits, should be added to the LineQubit named topology as well.

cc @mpharrigan

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/devicesgood first issueThis issue can be resolved by someone who is not familiar with the codebase. A good starting issue.kind/feature-requestDescribes new functionalitytriage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions