Skip to content

qadence.draw example plots

Mostly for quick, manual checking of correct plotting output.

from qadence import X, Y, kron
from qadence.draw import display

b = kron(X(0), Y(1))
%3 bdcd068a3e914050b0dd229106f804df 0 644869656fb6441d999a642291637480 X bdcd068a3e914050b0dd229106f804df--644869656fb6441d999a642291637480 1f16586584904ca3ad7c58c810b53c32 1 0e06f996c7bf42f097b6914be5ef570f 644869656fb6441d999a642291637480--0e06f996c7bf42f097b6914be5ef570f aec4a98ec2d8423d86a867c607772f76 e2b6235b0d484a5294e743d3df1df3ad Y 1f16586584904ca3ad7c58c810b53c32--e2b6235b0d484a5294e743d3df1df3ad e2b6235b0d484a5294e743d3df1df3ad--aec4a98ec2d8423d86a867c607772f76
from qadence import X, Y, chain
from qadence.draw import display

b = chain(X(0), Y(0))
%3 b3a29dec871c425f88cd9161d2bfcbe3 0 dd4c3d30c05c46e2bfe991b51e01c86c X b3a29dec871c425f88cd9161d2bfcbe3--dd4c3d30c05c46e2bfe991b51e01c86c 5477f86c3e7b4c9a812fd7e42d43ba8b Y dd4c3d30c05c46e2bfe991b51e01c86c--5477f86c3e7b4c9a812fd7e42d43ba8b 9778af4174804dfab7ac83ef01c6ef41 5477f86c3e7b4c9a812fd7e42d43ba8b--9778af4174804dfab7ac83ef01c6ef41
from qadence import X, Y, chain
from qadence.draw import display

b = chain(X(0), Y(1))
%3 c557a4d852b7421c99db78873f8534c2 0 68b1a37c1c7a472fb5a33db82dc21489 X c557a4d852b7421c99db78873f8534c2--68b1a37c1c7a472fb5a33db82dc21489 1fd769ef6b0740549a33a836400c8fdb 1 e933861c234945ecbd5fb0a63a45c27d 68b1a37c1c7a472fb5a33db82dc21489--e933861c234945ecbd5fb0a63a45c27d 6f90d3fac8dc45c5a37a1e8234c4cb30 e933861c234945ecbd5fb0a63a45c27d--6f90d3fac8dc45c5a37a1e8234c4cb30 74eb9864d5f84ad3899fea7266fb462e 8e84d0f7ac76467c8625e445a9270cb6 1fd769ef6b0740549a33a836400c8fdb--8e84d0f7ac76467c8625e445a9270cb6 69d6bf5cce164e4d80defc98ac2dec2d Y 8e84d0f7ac76467c8625e445a9270cb6--69d6bf5cce164e4d80defc98ac2dec2d 69d6bf5cce164e4d80defc98ac2dec2d--74eb9864d5f84ad3899fea7266fb462e
from qadence import X, Y, add
from qadence.draw import display

b = add(X(0), Y(1), X(2))
%3 cluster_a3cef04727f544a0861a8e59e867010e f0092c79cf2641dc9f4cbd158554572a 0 8603ee73f21d418e88bd2154387f3122 f0092c79cf2641dc9f4cbd158554572a--8603ee73f21d418e88bd2154387f3122 1f65aeb78a1c4c8aa9c375cec63f7864 1 8ebb83ea9d3047f490578e9ede283430 8603ee73f21d418e88bd2154387f3122--8ebb83ea9d3047f490578e9ede283430 6c7d634e395d4435a41da8963b7d3c84 6191ac767f9a41bda8727d8429bef37c AddBlock 1f65aeb78a1c4c8aa9c375cec63f7864--6191ac767f9a41bda8727d8429bef37c 0faf3ea7a221482095147643969077be 2 6191ac767f9a41bda8727d8429bef37c--6c7d634e395d4435a41da8963b7d3c84 c3c3847d97e24abe96f4df42ced73e93 144d033c90f348e9bc9aa4dc5b203356 0faf3ea7a221482095147643969077be--144d033c90f348e9bc9aa4dc5b203356 144d033c90f348e9bc9aa4dc5b203356--c3c3847d97e24abe96f4df42ced73e93
from qadence import CNOT, RX, HamEvo, X, Y, Z, chain, kron

rx = kron(RX(3,0.5), RX(2, "x"))
rx.tag = "rx"
gen = chain(Z(i) for i in range(4))

# `chain` puts things in sequence
block = chain(
    kron(X(0), Y(1), rx),
    CNOT(2,3),
    HamEvo(gen, 10)
)
%3 cluster_ebe8ccb2abe64e728753f573a70b7f48 cluster_b398880ae8dc426ca56c6a9091231e21 rx a89d37f27fc440818230358216f1b96a 0 4d1e057d0231470fab5587ae6ff93dc2 X a89d37f27fc440818230358216f1b96a--4d1e057d0231470fab5587ae6ff93dc2 61870cafeadd43a3b7d1935f74d06d87 1 77f174984d5b43b5886c78ac4b8994f9 4d1e057d0231470fab5587ae6ff93dc2--77f174984d5b43b5886c78ac4b8994f9 86510a0c40544f96a882c9e35dccfddd 77f174984d5b43b5886c78ac4b8994f9--86510a0c40544f96a882c9e35dccfddd ebb7c142b86940cc814792a79d800a8b 86510a0c40544f96a882c9e35dccfddd--ebb7c142b86940cc814792a79d800a8b 5861d63daca4464c80929246d999125d 50262db9be574546b3af3b859efd70f8 Y 61870cafeadd43a3b7d1935f74d06d87--50262db9be574546b3af3b859efd70f8 7bd9efa6f37f4d39a8529ad432f6a1ff 2 49f5da9a80d14f3ebfc677ba10c0b177 50262db9be574546b3af3b859efd70f8--49f5da9a80d14f3ebfc677ba10c0b177 23f92188364e4183a2d49d490c87a676 HamEvo 49f5da9a80d14f3ebfc677ba10c0b177--23f92188364e4183a2d49d490c87a676 23f92188364e4183a2d49d490c87a676--5861d63daca4464c80929246d999125d 5f5e772cf00f482ab85b6ac553f53e76 0d11a53f6a9a46688add0ba51f698264 RX(x) 7bd9efa6f37f4d39a8529ad432f6a1ff--0d11a53f6a9a46688add0ba51f698264 d08bc18044b144b39d8d4618fab63764 3 6c8c7ae371fc496d83f8fc58bade5fe1 0d11a53f6a9a46688add0ba51f698264--6c8c7ae371fc496d83f8fc58bade5fe1 f6ee33ab85a5433cb22f08b4cfb9cd5b t = 10 6c8c7ae371fc496d83f8fc58bade5fe1--f6ee33ab85a5433cb22f08b4cfb9cd5b f6ee33ab85a5433cb22f08b4cfb9cd5b--5f5e772cf00f482ab85b6ac553f53e76 14ff7cc3e90a47b9a9726b4ce537b539 af1e537868fa4d8a873584ba99fc3aa0 RX(0.5) d08bc18044b144b39d8d4618fab63764--af1e537868fa4d8a873584ba99fc3aa0 00963a0a9f9741bc827e424021af1069 X af1e537868fa4d8a873584ba99fc3aa0--00963a0a9f9741bc827e424021af1069 00963a0a9f9741bc827e424021af1069--6c8c7ae371fc496d83f8fc58bade5fe1 19c1375fe2404cd28a8df8acd6441cc1 00963a0a9f9741bc827e424021af1069--19c1375fe2404cd28a8df8acd6441cc1 19c1375fe2404cd28a8df8acd6441cc1--14ff7cc3e90a47b9a9726b4ce537b539
from qadence import feature_map, hea, chain

block = chain(feature_map(4, reupload_scaling="Tower"), hea(4,2))
%3 cluster_c74a579890234324aad83f6e42142fd4 HEA cluster_462f1f0a91c9474f8309835b282481f5 Tower Fourier FM 1a380e5ad1204ff9b7487b617f5f5a6b 0 4ba38a8610ba46c38718ca0e1605e8a0 RX(1.0*phi) 1a380e5ad1204ff9b7487b617f5f5a6b--4ba38a8610ba46c38718ca0e1605e8a0 5b5b90026c6a43cebeb0870c0139a170 1 0712681db2014394b9d4700c0819bf3b RX(theta₀) 4ba38a8610ba46c38718ca0e1605e8a0--0712681db2014394b9d4700c0819bf3b a41d9a683d0d47598057e3f895633bcb RY(theta₄) 0712681db2014394b9d4700c0819bf3b--a41d9a683d0d47598057e3f895633bcb 4bacbf5d200e48e4818091baf9000f94 RX(theta₈) a41d9a683d0d47598057e3f895633bcb--4bacbf5d200e48e4818091baf9000f94 c0e97fa0002d43b9be6567e32d66220f 4bacbf5d200e48e4818091baf9000f94--c0e97fa0002d43b9be6567e32d66220f e4c9504b211144f68fee63e9d41a6140 c0e97fa0002d43b9be6567e32d66220f--e4c9504b211144f68fee63e9d41a6140 bd12df91aa44413993a03fb7d729d097 RX(theta₁₂) e4c9504b211144f68fee63e9d41a6140--bd12df91aa44413993a03fb7d729d097 91d9704b7e8849e7b519231d527962ad RY(theta₁₆) bd12df91aa44413993a03fb7d729d097--91d9704b7e8849e7b519231d527962ad 9ea1d8eece0244c1836f95bf0099027a RX(theta₂₀) 91d9704b7e8849e7b519231d527962ad--9ea1d8eece0244c1836f95bf0099027a 36c6cf0b141a44b0babb35d66eb33dc8 9ea1d8eece0244c1836f95bf0099027a--36c6cf0b141a44b0babb35d66eb33dc8 0c3b5fd1e8334c7cae0cb489d86df686 36c6cf0b141a44b0babb35d66eb33dc8--0c3b5fd1e8334c7cae0cb489d86df686 6485994988d44b73a7daf9c565e087d4 0c3b5fd1e8334c7cae0cb489d86df686--6485994988d44b73a7daf9c565e087d4 0e2a97498a6a46d0b22544576bc2b02a 481d084331b64e1292083428d7f33293 RX(2.0*phi) 5b5b90026c6a43cebeb0870c0139a170--481d084331b64e1292083428d7f33293 e20929a95f7140409f7d125c3b8d8bed 2 5562ac8c88a74e1b8406f8bb7bc23ca2 RX(theta₁) 481d084331b64e1292083428d7f33293--5562ac8c88a74e1b8406f8bb7bc23ca2 05e247e89d9241b1909da0301a48be4a RY(theta₅) 5562ac8c88a74e1b8406f8bb7bc23ca2--05e247e89d9241b1909da0301a48be4a c30c0de896c3499a8728b328e83ee18c RX(theta₉) 05e247e89d9241b1909da0301a48be4a--c30c0de896c3499a8728b328e83ee18c 7f96e4998bdb40c79564380913f24604 X c30c0de896c3499a8728b328e83ee18c--7f96e4998bdb40c79564380913f24604 7f96e4998bdb40c79564380913f24604--c0e97fa0002d43b9be6567e32d66220f 6651836443bc4a779d01d685944048a1 7f96e4998bdb40c79564380913f24604--6651836443bc4a779d01d685944048a1 45dae3c929e54534bf56bec741777753 RX(theta₁₃) 6651836443bc4a779d01d685944048a1--45dae3c929e54534bf56bec741777753 f469ef11e9fc4aeba7ff8bc50fbf1a66 RY(theta₁₇) 45dae3c929e54534bf56bec741777753--f469ef11e9fc4aeba7ff8bc50fbf1a66 96ff4aaed49b47e4855ae0ab37ab53e3 RX(theta₂₁) f469ef11e9fc4aeba7ff8bc50fbf1a66--96ff4aaed49b47e4855ae0ab37ab53e3 89bcbd63c1e24c9ebeb72652cbd87fcc X 96ff4aaed49b47e4855ae0ab37ab53e3--89bcbd63c1e24c9ebeb72652cbd87fcc 89bcbd63c1e24c9ebeb72652cbd87fcc--36c6cf0b141a44b0babb35d66eb33dc8 fca3ff52ca894a30a0010a61204a2fc5 89bcbd63c1e24c9ebeb72652cbd87fcc--fca3ff52ca894a30a0010a61204a2fc5 fca3ff52ca894a30a0010a61204a2fc5--0e2a97498a6a46d0b22544576bc2b02a d563996141e642a1b09e9e4109d72a50 de12cdd6f9fb40cba250a7547d86a79f RX(3.0*phi) e20929a95f7140409f7d125c3b8d8bed--de12cdd6f9fb40cba250a7547d86a79f 6a8182e82b3245f3a92b4fe19d039772 3 2952dfa56ad744e69d0c128af2ede6d9 RX(theta₂) de12cdd6f9fb40cba250a7547d86a79f--2952dfa56ad744e69d0c128af2ede6d9 98c1c97caa434b25b729a5846dc98926 RY(theta₆) 2952dfa56ad744e69d0c128af2ede6d9--98c1c97caa434b25b729a5846dc98926 22df7ecf63aa45ce90df2437c0d4dd43 RX(theta₁₀) 98c1c97caa434b25b729a5846dc98926--22df7ecf63aa45ce90df2437c0d4dd43 cbea9cdfe5084aedb0700255bc911ddb 22df7ecf63aa45ce90df2437c0d4dd43--cbea9cdfe5084aedb0700255bc911ddb ed71ba453b3141e7a734adb6793766dc X cbea9cdfe5084aedb0700255bc911ddb--ed71ba453b3141e7a734adb6793766dc ed71ba453b3141e7a734adb6793766dc--6651836443bc4a779d01d685944048a1 4d12910d2c8447848d88df430d70a9aa RX(theta₁₄) ed71ba453b3141e7a734adb6793766dc--4d12910d2c8447848d88df430d70a9aa 9ead29859da243f38ed3fbcd21786eaf RY(theta₁₈) 4d12910d2c8447848d88df430d70a9aa--9ead29859da243f38ed3fbcd21786eaf 08ce18f1197447d7899b59a96161b8b8 RX(theta₂₂) 9ead29859da243f38ed3fbcd21786eaf--08ce18f1197447d7899b59a96161b8b8 394fec3b91ba4d98b771975510194a3d 08ce18f1197447d7899b59a96161b8b8--394fec3b91ba4d98b771975510194a3d 1fd6f2ef6e274f8496c6b64c1cda6ab1 X 394fec3b91ba4d98b771975510194a3d--1fd6f2ef6e274f8496c6b64c1cda6ab1 1fd6f2ef6e274f8496c6b64c1cda6ab1--fca3ff52ca894a30a0010a61204a2fc5 1fd6f2ef6e274f8496c6b64c1cda6ab1--d563996141e642a1b09e9e4109d72a50 f0fb2c0c47284d84aeba73f476669498 efef77ce64cc4304a8b58c7d932f666c RX(4.0*phi) 6a8182e82b3245f3a92b4fe19d039772--efef77ce64cc4304a8b58c7d932f666c 248cb01e84c5416f888a16d775c17a54 RX(theta₃) efef77ce64cc4304a8b58c7d932f666c--248cb01e84c5416f888a16d775c17a54 ff4f527068be4b4ba0cec259ab472ed6 RY(theta₇) 248cb01e84c5416f888a16d775c17a54--ff4f527068be4b4ba0cec259ab472ed6 f995f3d3352b4c27bff1b1858bb1319f RX(theta₁₁) ff4f527068be4b4ba0cec259ab472ed6--f995f3d3352b4c27bff1b1858bb1319f 6cf2c1a7f1f441b1aa34030e507240a8 X f995f3d3352b4c27bff1b1858bb1319f--6cf2c1a7f1f441b1aa34030e507240a8 6cf2c1a7f1f441b1aa34030e507240a8--cbea9cdfe5084aedb0700255bc911ddb ee2eefa66c2d489bac873e34b08b6260 6cf2c1a7f1f441b1aa34030e507240a8--ee2eefa66c2d489bac873e34b08b6260 5220a1dcdf0740048b7009d7bec909d2 RX(theta₁₅) ee2eefa66c2d489bac873e34b08b6260--5220a1dcdf0740048b7009d7bec909d2 ea88506e9a48416c90e016455cd5d019 RY(theta₁₉) 5220a1dcdf0740048b7009d7bec909d2--ea88506e9a48416c90e016455cd5d019 16967fac1ca2443a9c430fe4e3171100 RX(theta₂₃) ea88506e9a48416c90e016455cd5d019--16967fac1ca2443a9c430fe4e3171100 36c0465caf8b41b98daf9bbbaab4e835 X 16967fac1ca2443a9c430fe4e3171100--36c0465caf8b41b98daf9bbbaab4e835 36c0465caf8b41b98daf9bbbaab4e835--394fec3b91ba4d98b771975510194a3d 1bb0a5e83b50472abbe9406e6bb48097 36c0465caf8b41b98daf9bbbaab4e835--1bb0a5e83b50472abbe9406e6bb48097 1bb0a5e83b50472abbe9406e6bb48097--f0fb2c0c47284d84aeba73f476669498
from qadence import QuantumModel, QuantumCircuit, total_magnetization, hea

model = QuantumModel(QuantumCircuit(3, hea(3,2)), total_magnetization(3))
%3 cluster_74a643efccc34f6b8cefec6fd21da602 Obs. cluster_6a8471cce10747e39b39671ee36263ad cluster_db95263ec2504c0192c8472091a29d0d HEA 50e664db560149bb95fb63c337b3751a 0 cd1a197506f64f698130242445158a92 RX(theta₀) 50e664db560149bb95fb63c337b3751a--cd1a197506f64f698130242445158a92 bdd997da32654d1e892d45ae40f1c662 1 d021e75675364fa0beb70c2a6bf1a9ad RY(theta₃) cd1a197506f64f698130242445158a92--d021e75675364fa0beb70c2a6bf1a9ad 961b78a0340b4a13ad6053d822bb23e7 RX(theta₆) d021e75675364fa0beb70c2a6bf1a9ad--961b78a0340b4a13ad6053d822bb23e7 dce747d290b34d8d83637ee0bf91a2e8 961b78a0340b4a13ad6053d822bb23e7--dce747d290b34d8d83637ee0bf91a2e8 428aa9be4708441db054843c3153e509 dce747d290b34d8d83637ee0bf91a2e8--428aa9be4708441db054843c3153e509 172fd885656c46ceb4c3d2b7d3c3293b RX(theta₉) 428aa9be4708441db054843c3153e509--172fd885656c46ceb4c3d2b7d3c3293b a70be6d809d34ebd9fa3efc510651a87 RY(theta₁₂) 172fd885656c46ceb4c3d2b7d3c3293b--a70be6d809d34ebd9fa3efc510651a87 0aaceda004f84e369e5175c81191530a RX(theta₁₅) a70be6d809d34ebd9fa3efc510651a87--0aaceda004f84e369e5175c81191530a 8b59344f30d1472da567aee769a86e69 0aaceda004f84e369e5175c81191530a--8b59344f30d1472da567aee769a86e69 f5c8108a0c934e0da97aaf23c8fabcb9 8b59344f30d1472da567aee769a86e69--f5c8108a0c934e0da97aaf23c8fabcb9 c927151f6c5342e8b0dcba74189bead2 f5c8108a0c934e0da97aaf23c8fabcb9--c927151f6c5342e8b0dcba74189bead2 feeb0c3770394e498f918dcf8b6c73a2 c927151f6c5342e8b0dcba74189bead2--feeb0c3770394e498f918dcf8b6c73a2 5998738fef06438fb8b64c27a4ccf66a 97e6bf210c834b3d96f9918b1d72610c RX(theta₁) bdd997da32654d1e892d45ae40f1c662--97e6bf210c834b3d96f9918b1d72610c 10aab8619514477eaa24108a8e633611 2 e33ac66310344ef49c4b69f7c49ef1c7 RY(theta₄) 97e6bf210c834b3d96f9918b1d72610c--e33ac66310344ef49c4b69f7c49ef1c7 b7b9401b351a41c0be98b7d36b0b3b81 RX(theta₇) e33ac66310344ef49c4b69f7c49ef1c7--b7b9401b351a41c0be98b7d36b0b3b81 15efdb497bfb43bb837c3713a3dac702 X b7b9401b351a41c0be98b7d36b0b3b81--15efdb497bfb43bb837c3713a3dac702 15efdb497bfb43bb837c3713a3dac702--dce747d290b34d8d83637ee0bf91a2e8 831a6d9de166424fadd381a0329d2d35 15efdb497bfb43bb837c3713a3dac702--831a6d9de166424fadd381a0329d2d35 1047be2bdf5c4111adb1c04d07376e64 RX(theta₁₀) 831a6d9de166424fadd381a0329d2d35--1047be2bdf5c4111adb1c04d07376e64 038c7c4c9e1742a9b16c9c298f6577bc RY(theta₁₃) 1047be2bdf5c4111adb1c04d07376e64--038c7c4c9e1742a9b16c9c298f6577bc 6f526d4c87c241ec90e78f5790fed3cb RX(theta₁₆) 038c7c4c9e1742a9b16c9c298f6577bc--6f526d4c87c241ec90e78f5790fed3cb 0694e3e7bb1d4104819ac7383bb18f5e X 6f526d4c87c241ec90e78f5790fed3cb--0694e3e7bb1d4104819ac7383bb18f5e 0694e3e7bb1d4104819ac7383bb18f5e--8b59344f30d1472da567aee769a86e69 c013b747960a4ffe87aeff7920c28789 0694e3e7bb1d4104819ac7383bb18f5e--c013b747960a4ffe87aeff7920c28789 624fa994cf54438f88ea1d84a23de4e4 AddBlock c013b747960a4ffe87aeff7920c28789--624fa994cf54438f88ea1d84a23de4e4 624fa994cf54438f88ea1d84a23de4e4--5998738fef06438fb8b64c27a4ccf66a c46e19d20fa04b4ca1de8452594cbf31 6401a946cf804a8c9a6b86789184f0df RX(theta₂) 10aab8619514477eaa24108a8e633611--6401a946cf804a8c9a6b86789184f0df 178b347b75cf4ca783dcc33cdc3ebc2a RY(theta₅) 6401a946cf804a8c9a6b86789184f0df--178b347b75cf4ca783dcc33cdc3ebc2a 054f642b5fe04dfe9e7e5fe999483e2a RX(theta₈) 178b347b75cf4ca783dcc33cdc3ebc2a--054f642b5fe04dfe9e7e5fe999483e2a eb33899daac5444f9887aec8518b9066 054f642b5fe04dfe9e7e5fe999483e2a--eb33899daac5444f9887aec8518b9066 f7ace9f2f1384ed3a3e35da10b0a8074 X eb33899daac5444f9887aec8518b9066--f7ace9f2f1384ed3a3e35da10b0a8074 f7ace9f2f1384ed3a3e35da10b0a8074--831a6d9de166424fadd381a0329d2d35 9ca0df96c9b64241b2865c1583d47699 RX(theta₁₁) f7ace9f2f1384ed3a3e35da10b0a8074--9ca0df96c9b64241b2865c1583d47699 a5cd5c6e0c0c46d4ab32c56d26c7c555 RY(theta₁₄) 9ca0df96c9b64241b2865c1583d47699--a5cd5c6e0c0c46d4ab32c56d26c7c555 fed78598fb574e239dd3b91867d6c028 RX(theta₁₇) a5cd5c6e0c0c46d4ab32c56d26c7c555--fed78598fb574e239dd3b91867d6c028 db03782722784a11b3edfd8406b0d057 fed78598fb574e239dd3b91867d6c028--db03782722784a11b3edfd8406b0d057 a6c65cb8d3ba4a66a5760dbb877bae3b X db03782722784a11b3edfd8406b0d057--a6c65cb8d3ba4a66a5760dbb877bae3b a6c65cb8d3ba4a66a5760dbb877bae3b--c013b747960a4ffe87aeff7920c28789 a3202b824452457fa8c8363bfddf3671 a6c65cb8d3ba4a66a5760dbb877bae3b--a3202b824452457fa8c8363bfddf3671 a3202b824452457fa8c8363bfddf3671--c46e19d20fa04b4ca1de8452594cbf31
from qadence import *

b = chain(SWAP(0,1), SWAP(0,3))
%3 bb71df26050445639d1e8c1b2c8d8c99 0 dcbb6fb63e9c401fbbdb9f4f6506364e bb71df26050445639d1e8c1b2c8d8c99--dcbb6fb63e9c401fbbdb9f4f6506364e f6135cc68116445d9f2e13be883dd144 1 cc303c9b34c5498588347a32b4739d84 c391a23664f248159e6ca215e3776e11 dcbb6fb63e9c401fbbdb9f4f6506364e--c391a23664f248159e6ca215e3776e11 daec8e77ef7d456596a17d1776c6eba2 cc303c9b34c5498588347a32b4739d84--daec8e77ef7d456596a17d1776c6eba2 e79b70c4587f4593a22c69b94007df06 170c7486dfbc400b9416e7a7640dff8f daec8e77ef7d456596a17d1776c6eba2--170c7486dfbc400b9416e7a7640dff8f 4d84772562bc40b7a6257733b1b6a2c2 e79b70c4587f4593a22c69b94007df06--4d84772562bc40b7a6257733b1b6a2c2 4bf208a078e246d8946db49cc3e8fa39 ff62ee9f2335475bbdc290ad5575a323 f6135cc68116445d9f2e13be883dd144--ff62ee9f2335475bbdc290ad5575a323 74d29c7b16684f929d0e3cc5eedec94b 2 ff62ee9f2335475bbdc290ad5575a323--cc303c9b34c5498588347a32b4739d84 702edfc6c9aa4b8fa3bf5d2a57fb7f79 c391a23664f248159e6ca215e3776e11--702edfc6c9aa4b8fa3bf5d2a57fb7f79 e45b101277864ff497482a33ec4b3355 702edfc6c9aa4b8fa3bf5d2a57fb7f79--e45b101277864ff497482a33ec4b3355 e45b101277864ff497482a33ec4b3355--4bf208a078e246d8946db49cc3e8fa39 272af0b33c464d278561706179c3f98c a60ecbf29f2d478aa5ebf2977fd80f5f 74d29c7b16684f929d0e3cc5eedec94b--a60ecbf29f2d478aa5ebf2977fd80f5f fdd29404036145a9bded7a6c1fafedd2 3 968c93e675894094a46be2f7bce5787b a60ecbf29f2d478aa5ebf2977fd80f5f--968c93e675894094a46be2f7bce5787b 5f117a20753043998825335ffe0edec8 968c93e675894094a46be2f7bce5787b--5f117a20753043998825335ffe0edec8 3ae954e7803a4a6e82ca31c985eb27d6 5f117a20753043998825335ffe0edec8--3ae954e7803a4a6e82ca31c985eb27d6 3ae954e7803a4a6e82ca31c985eb27d6--272af0b33c464d278561706179c3f98c 128bb356e67040f6b380500b98d0bf2a fe050210119b49d4b8da31fd514985f0 fdd29404036145a9bded7a6c1fafedd2--fe050210119b49d4b8da31fd514985f0 ed0275c111df467f9f767118f61304a9 fe050210119b49d4b8da31fd514985f0--ed0275c111df467f9f767118f61304a9 e14eeca2b9ad45a88fb26693b503aad2 ed0275c111df467f9f767118f61304a9--e14eeca2b9ad45a88fb26693b503aad2 e14eeca2b9ad45a88fb26693b503aad2--e79b70c4587f4593a22c69b94007df06 170c7486dfbc400b9416e7a7640dff8f--128bb356e67040f6b380500b98d0bf2a
from qadence import *

b = chain(CPHASE(0, 1, 0.5), CPHASE(0, 2, 0.5), CPHASE(0, 3, 0.5))
%3 974f1d4cf46c43ca844c516494b8713d 0 07401233c0a14833ada32000fe5a992e 974f1d4cf46c43ca844c516494b8713d--07401233c0a14833ada32000fe5a992e 70348b1d255d4c44aa0b7b14751b62fa 1 681134cc213a4d5fb6dd858c84b0b448 07401233c0a14833ada32000fe5a992e--681134cc213a4d5fb6dd858c84b0b448 1805991430cd4cec835efa46d6d202f3 681134cc213a4d5fb6dd858c84b0b448--1805991430cd4cec835efa46d6d202f3 03f3c193134a4061afd324197817dbd3 1805991430cd4cec835efa46d6d202f3--03f3c193134a4061afd324197817dbd3 7359a66d73b14e209e383bb87804c289 3988302ea32a41bb92742e01748e1936 PHASE(0.5) 70348b1d255d4c44aa0b7b14751b62fa--3988302ea32a41bb92742e01748e1936 d28f13baf19b4590a2715099d1924a28 2 3988302ea32a41bb92742e01748e1936--07401233c0a14833ada32000fe5a992e 487fa124322144f0a9b5cad68a7627dd 3988302ea32a41bb92742e01748e1936--487fa124322144f0a9b5cad68a7627dd 98ba4713706546b8b7ec849cce0ceeeb 487fa124322144f0a9b5cad68a7627dd--98ba4713706546b8b7ec849cce0ceeeb 98ba4713706546b8b7ec849cce0ceeeb--7359a66d73b14e209e383bb87804c289 160a1ca9d8e1444aa2414d0a380e6f0e ccd9c3a98a1f4664bf291a895ae5be2f d28f13baf19b4590a2715099d1924a28--ccd9c3a98a1f4664bf291a895ae5be2f 59344050c3184d94853e75ed608463e5 3 f7739a3b4bbd423a97b508e53774a09e PHASE(0.5) ccd9c3a98a1f4664bf291a895ae5be2f--f7739a3b4bbd423a97b508e53774a09e f7739a3b4bbd423a97b508e53774a09e--681134cc213a4d5fb6dd858c84b0b448 adf881c9ebac4b57bd92a2a3ae4cd37f f7739a3b4bbd423a97b508e53774a09e--adf881c9ebac4b57bd92a2a3ae4cd37f adf881c9ebac4b57bd92a2a3ae4cd37f--160a1ca9d8e1444aa2414d0a380e6f0e d7b31298915245b0868196f2f5118cbb 42dd3e2489f74b3aa368830096257b74 59344050c3184d94853e75ed608463e5--42dd3e2489f74b3aa368830096257b74 4f12de3296684886b7526405d46943ef 42dd3e2489f74b3aa368830096257b74--4f12de3296684886b7526405d46943ef bf5d737cf9f941e48c4109794ef3407f PHASE(0.5) 4f12de3296684886b7526405d46943ef--bf5d737cf9f941e48c4109794ef3407f bf5d737cf9f941e48c4109794ef3407f--1805991430cd4cec835efa46d6d202f3 bf5d737cf9f941e48c4109794ef3407f--d7b31298915245b0868196f2f5118cbb

Developer documentation

This section contains examples in pure graphviz that can be used to understand roughly what is done in the actual drawing backend.

import graphviz

font_name = "Sans-Serif"
font_size = "8"

graph_attr = {
    "rankdir": "LR",  # LR = left to right, TB = top to bottom
    "nodesep": "0.1",  # In inches, tells distance between nodes without edges
    "compound": "true",  # Needed to draw properly edges in hamevo when content is hidden
    "splines": "false",  # Needed to draw control gates vertical lines one over the other
}  # These are the default values for graphs

node_attr = {
    "shape": "box",  # 'box' for normal nodes, 'point' for control gates or 'plaintext' for starting nodes (the qubit label).
    "style": "rounded",  # Unfortunately we can't specify the radius of the rounded, at least for this version
    "fontname": font_name,
    "fontsize": font_size,
    "width": "0.1",  # In inches, it doesn't get tinier than the label font.
    "height": "0.1"  # In inches, it doesn't get tinier than the label font.
}  # These are the defaults values that can be overridden at node declaration.

default_cluster_attr = {
    "fontname": font_name,
    "fontsize": font_size,
    "labelloc": "b",  # location of cluster label. b as bottom, t as top
    "style": "rounded"
} # These are the defaults values that can be overridden at sub graph declaration

hamevo_cluster_attr = {
    "label": "HamEvo(t=10)"
}
hamevo_cluster_attr.update(default_cluster_attr)

h = graphviz.Graph(graph_attr=graph_attr, node_attr=node_attr)
h.node("Hello World!")
h

# Define graph
h = graphviz.Graph(node_attr=node_attr, graph_attr=graph_attr)

# Add start and end nodes
for i in range(4):
    h.node(f's{i}', shape="plaintext", label=f'{i}', group=f"{i}")
    h.node(f'e{i}', style='invis', group=f"{i}")

# Add nodes
h.node('X', group="0")
h.node('Y', group="1")

# Add hamevo and its nodes
hamevo = graphviz.Graph(name='cluster_hamevo', graph_attr=hamevo_cluster_attr)
for i in range(4):
    hamevo.node(f'z{i}', shape="box", style="invis", label=f'{i}', group=f"{i}")
h.subgraph(hamevo)

# Add rx gates cluster and its nodes
cluster_attr = {"label": "RX gates"}
cluster_attr.update(default_cluster_attr)
cluster = graphviz.Graph(name="cluster_0", graph_attr=cluster_attr)
cluster.node('RX(x)', group="2")
cluster.node('RX(0.5)', group="3")
h.subgraph(cluster)

h.node('cnot0', label='', shape='point', width='0.1', group='0')
h.node('cnot1', label='X', group='1')
h.node('cnot2', label='', shape='point', width='0.1', group='2')
h.node('cnot3', label='', shape='point', width='0.1', group='3')

# Add edges
h.edge('s0', 'X')
h.edge('X', 'cnot0')
h.edge('cnot0', 'z0', lhead='cluster_hamevo')
h.edge('z0', 'e0', ltail='cluster_hamevo')
h.edge('s1', 'Y')
h.edge('Y', 'cnot1')
h.edge('cnot1', 'z1', lhead='cluster_hamevo')
h.edge('z1', 'e1', ltail='cluster_hamevo')
h.edge('s2', 'RX(x)')
h.edge('RX(x)', 'cnot2')
h.edge('cnot2', 'z2', lhead='cluster_hamevo')
h.edge('z2', 'e2', ltail='cluster_hamevo')
h.edge('s3', 'RX(0.5)')
h.edge('RX(0.5)', 'cnot3')
h.edge('cnot3', 'z3', lhead='cluster_hamevo')
h.edge('z3', 'e3', ltail='cluster_hamevo')
h.edge('cnot1', 'cnot0', constraint='false')  # constraint: false is needed to draw vertical edges
h.edge('cnot1', 'cnot2', constraint='false')  # constraint: false is needed to draw vertical edges
h.edge('cnot1', 'cnot3', constraint='false')  # constraint: false is needed to draw vertical edges
h

Example of cluster of clusters

# Define graph
h = graphviz.Graph(node_attr=node_attr, graph_attr=graph_attr)

# Define start and end nodes
for i in range(4):
    h.node(f's{i}', shape="plaintext", label=f'{i}', group=f"{i}")
    h.node(f'e{i}', style='invis', group=f"{i}")

# Define outer cluster
cluster_attr = {"label": "Outer cluster"}
cluster_attr.update(default_cluster_attr)
outer_cluster = graphviz.Graph(name="cluster_outer", graph_attr=cluster_attr)

# Define inner cluster 1 and its nodes
cluster_attr = {"label": "Inner cluster 1"}
cluster_attr.update(default_cluster_attr)
inner1_cluster = graphviz.Graph(name="cluster_inner1", graph_attr=cluster_attr)
inner1_cluster.node("a0", group="0")
inner1_cluster.node("a1", group="1")
outer_cluster.subgraph(inner1_cluster)

# Define inner cluster 2 and its nodes
cluster_attr = {"label": "Inner cluster 2"}
cluster_attr.update(default_cluster_attr)
inner2_cluster = graphviz.Graph(name="cluster_inner2", graph_attr=cluster_attr)
inner2_cluster.node("a2", group="2")
inner2_cluster.node("a3", group="3")
outer_cluster.subgraph(inner2_cluster)

# This has to be done here, after inner clusters definitions
h.subgraph(outer_cluster)

# Define more nodes
for i in range(4):
    h.node(f"b{i}", group=f"{i}")

for i in range(4):
    h.edge(f's{i}', f'a{i}')
    h.edge(f'a{i}', f'b{i}')
    h.edge(f'b{i}', f'e{i}')

h