EntangledQuery
  • Threads
  • Categories
  • Users
  • Seminar
  • forum
  • group
  • theaters
  • search
  1. Threads
  2. Qiskit
chevron_left Qiskit

What is DAG circuit? How can I translate a DAG circuit to a QuantumCircuit?

  • forum 1 reply
  • last reply by Meng Sept. 3, 2021
  • Last
  • link
    Kosei
    Members 8 posts
    Sept. 3, 2021, 1:09 a.m. Sept. 3, 2021, 1:09 a.m.
    link

    I am trying to use this function github.com/Qiskit/qiskit-terra/blob/master/qiskit/transpiler/passes/routing/basic_swap.py and it take a DAG as input. The output is also a DAG, so I am trying to convert it back to usual QuantumCircuit

  • edit

    Thread title has been changed from What is DAG circuit? How can I translate a DAG circuit to a quantum circuit?.

    • By Kosei on Sept. 3, 2021, 1:10 a.m..
  • link
    Meng
    Members 22 posts
    Sept. 3, 2021, 12:34 p.m. Sept. 3, 2021, 12:34 p.m.
    link

    You can use the qiskit.converters module which includes (among others):
    qiskit.converters.circuit_to_dag(): qiskit.org/documentation/stubs/qiskit.converters.circuit_to_dag.html?highlight=dag#qiskit.converters.circuit_to_dag
    qiskit.converters.dag_to_circuit(): qiskit.org/documentation/stubs/qiskit.converters.dag_to_circuit.html?highlight=dag#qiskit.converters.dag_to_circuit

    And if you are trying to perform the basic_swap on a circuit, you can also do:

    swap_pass = BasicSwap(coupling_map)
    swapped_circuit = swap_pass(circuit)
    

    siyu likes this.

    favorite 1

There are no more posts in this thread.

  • EntangledQuery