NOTE: At the moment this method is correct, however, this information might be out of date once the 0.9 release of Qiskit is deployed.
Hi Samuel, if you have a dag circuit and you want to access information about the nodes, you need to call dag_circuit.multi_graph.nodes[index_of_node]
The information you can get from a node in the circuit is a dictionary containing the following:
- type (either "in", "out", or "op")
- name (either a qubit, classical bit, or an operation name)
- wire (the Register Object of the qubit or classical bit that the wire is attached to)
An "op" node will will have these other values in addition to the ones above (excluding the "wire" value):
- 'op' (The data type of the operation)
- qargs (The qubits this gate is applied to)
- cargs (The classical bits this gate is applied to)
- condition
In your example where you have an $H$ Gate at node 9 and a $U_3(\theta=0.1, \phi=0.2, \lambda=-0.5)$ Gate at node 11, if you were to call print(dag_circuit.multi_graph.nodes[8])
and print(dag_circuit.multi_graph.nodes[10])
, you would receive the following output:
{'type': 'op', 'op': <qiskit.extensions.standard.h.HGate object at "some_memory_address">, 'name': 'h', 'qargs': [(QuantumRegister(1, 'q'), 0)], 'cargs': [], 'condition': None}
{'type': 'op', 'op': <qiskit.extensions.standard.u3.U3Gate object at "some_memory_address">, 'name': 'u3', 'qargs': [(QuantumRegister(1, 'q'), 0)], 'cargs': [], 'condition': None}