@@ -5994,18 +5994,18 @@ QuantumCircuit.prototype.exportQuirk = function(decompose) {
59945994 isDecomposeCustomCircuit = true ;
59955995 }
59965996 }
5997-
5998- if ( isDecomposeCustomCircuit ) {
5999- circuit . gates . map ( function ( circuitGate , index ) {
6000- circuitGate . map ( function ( gateToRemove ) {
6001- if ( gateToRemove && gateToRemove . name == gate . name ) {
6002- circuit . removeGate ( gateToRemove . id ) ;
6003- }
6004- } ) ;
6005- } ) ;
6006- } else {
6007- gatesToBeAdded = [ ] ;
6008- }
5997+ }
5998+
5999+ if ( isDecomposeCustomCircuit ) {
6000+ circuit . gates . map ( function ( circuitGate , index ) {
6001+ circuitGate . map ( function ( gateToRemove ) {
6002+ if ( gateToRemove && gateToRemove . name == gate . name ) {
6003+ circuit . removeGate ( gateToRemove . id ) ;
6004+ }
6005+ } ) ;
6006+ } ) ;
6007+ } else {
6008+ gatesToBeAdded = [ ] ;
60096009 }
60106010 }
60116011 }
@@ -6019,6 +6019,26 @@ QuantumCircuit.prototype.exportQuirk = function(decompose) {
60196019 }
60206020 } ) ;
60216021
6022+ var previousColumn = null ;
6023+ var previousGate = null ;
6024+ for ( var column = 0 ; column < numCols ; column ++ ) {
6025+ for ( var wire = 0 ; wire < circuit . numQubits ; wire ++ ) {
6026+ var gate = circuit . getGateAt ( column , wire ) ;
6027+ if ( gate ) {
6028+ // if(previousGate){
6029+ // console.log(previousGate.name, gate.name, previousGate.connector, previousColumn, column)
6030+ // }
6031+ if ( previousGate && previousGate . name != gate . name && previousGate . connector != 0 && previousColumn == column ) {
6032+ circuit . removeGate ( gate . id ) ;
6033+ circuit . insertGate ( gate . name , gate . column + 1 , gate . wires , gate . options ) ;
6034+ // console.log(gate.name, previousColumn, column)
6035+ }
6036+ previousGate = gate ;
6037+ previousColumn = column ;
6038+ }
6039+ }
6040+ }
6041+
60226042 var numCols = circuit . numCols ( ) ;
60236043 for ( var column = 0 ; column < numCols ; column ++ ) {
60246044 var quirkColumn = [ ] ;
0 commit comments