DAGCircuit.substitute_node¶
- DAGCircuit.substitute_node(node, op, inplace=False)[source]¶
Replace a DAGNode with a single instruction. qargs, cargs and conditions for the new instruction will be inferred from the node to be replaced. The new instruction will be checked to match the shape of the replaced instruction.
- Parameters
node (DAGNode) – Node to be replaced
op (qiskit.circuit.Instruction) – The
qiskit.circuit.Instruction
instance to be added to the DAGinplace (bool) – Optional, default False. If True, existing DAG node will be modified to include op. Otherwise, a new DAG node will be used.
- Returns
the new node containing the added instruction.
- Return type
- Raises
DAGCircuitError – If replacement instruction was incompatible with
location of target node. –