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 b3f694cc121340fa88ac6445e401181c 0 79136da0351844478d18f97181b1c4dd X b3f694cc121340fa88ac6445e401181c--79136da0351844478d18f97181b1c4dd 1b099e6f5cee4a6082f99fc56f686e61 1 5b215cd2ad4f404b8a0532021b6d9dbd 79136da0351844478d18f97181b1c4dd--5b215cd2ad4f404b8a0532021b6d9dbd f007dc81218f40109f9e92eb8fa1c835 fe9885dcf13140b3b8d9b8d9b49c1f2c Y 1b099e6f5cee4a6082f99fc56f686e61--fe9885dcf13140b3b8d9b8d9b49c1f2c fe9885dcf13140b3b8d9b8d9b49c1f2c--f007dc81218f40109f9e92eb8fa1c835
from qadence import X, Y, chain
from qadence.draw import display

b = chain(X(0), Y(0))
%3 64bfacd2954b4c0e91d005d6f642de18 0 4ee473211a674c1eada68cf640b97b34 X 64bfacd2954b4c0e91d005d6f642de18--4ee473211a674c1eada68cf640b97b34 f62a8a8198ed49b7b487715ac1e6e77b Y 4ee473211a674c1eada68cf640b97b34--f62a8a8198ed49b7b487715ac1e6e77b 2e51a95f8be449ec9b1b9d37bd5b120c f62a8a8198ed49b7b487715ac1e6e77b--2e51a95f8be449ec9b1b9d37bd5b120c
from qadence import X, Y, chain
from qadence.draw import display

b = chain(X(0), Y(1))
%3 2f2e6d8987424806b4bcda3568813ddc 0 a897cb7fb6a245f3a8948a2c0c69b8fb X 2f2e6d8987424806b4bcda3568813ddc--a897cb7fb6a245f3a8948a2c0c69b8fb 283f23b8f2914c978bec765f84518980 1 c260962806674f2a9ca7f8025e18c758 a897cb7fb6a245f3a8948a2c0c69b8fb--c260962806674f2a9ca7f8025e18c758 5b68ea8a309943e09c77867b9d86aea6 c260962806674f2a9ca7f8025e18c758--5b68ea8a309943e09c77867b9d86aea6 2bb05afe74ea4eedbbd3feafd256eb4a eab94f6356224226b7329e0657338dde 283f23b8f2914c978bec765f84518980--eab94f6356224226b7329e0657338dde 175669d10f3b4cef8798592b5025b907 Y eab94f6356224226b7329e0657338dde--175669d10f3b4cef8798592b5025b907 175669d10f3b4cef8798592b5025b907--2bb05afe74ea4eedbbd3feafd256eb4a
from qadence import X, Y, add
from qadence.draw import display

b = add(X(0), Y(1), X(2))
%3 cluster_d7b0b17018834f80bd9d04dc1cfe951c b3724645e4c24b2a9371781425c760b6 0 114b1360e4d34334aa76cc0e631d5bfc b3724645e4c24b2a9371781425c760b6--114b1360e4d34334aa76cc0e631d5bfc e5ae3b5beb044b33bcf44bf39746b25b 1 5c244ca74a15492c9451921df705e438 114b1360e4d34334aa76cc0e631d5bfc--5c244ca74a15492c9451921df705e438 bed30228b3c14941acc26ef8a2a23ae4 1d65c656a7bb4ea0a701822b1a714a24 AddBlock e5ae3b5beb044b33bcf44bf39746b25b--1d65c656a7bb4ea0a701822b1a714a24 000c09e82638448591654fe07286ff32 2 1d65c656a7bb4ea0a701822b1a714a24--bed30228b3c14941acc26ef8a2a23ae4 08494d49bc204d87ab36c72e9846a694 64d8e89090064a1caf7321bdcae3b15b 000c09e82638448591654fe07286ff32--64d8e89090064a1caf7321bdcae3b15b 64d8e89090064a1caf7321bdcae3b15b--08494d49bc204d87ab36c72e9846a694
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_cd004fd53dcf4de1809a970ce51815b6 cluster_5bcfe52dbf1e4936af372370913d7eb4 rx a018b84d5f8843dbae6493348720cac2 0 7a769e206023429ca1127f32e85a3e91 X a018b84d5f8843dbae6493348720cac2--7a769e206023429ca1127f32e85a3e91 b814c1375c0d4b45ac962966e53440b6 1 0cd9644c60514a80938ddac650cce6ed 7a769e206023429ca1127f32e85a3e91--0cd9644c60514a80938ddac650cce6ed e4946ac5e6b1401ba0b801d8f678b00c 0cd9644c60514a80938ddac650cce6ed--e4946ac5e6b1401ba0b801d8f678b00c 0ca3e19b546a4ebf948ad894cda10897 e4946ac5e6b1401ba0b801d8f678b00c--0ca3e19b546a4ebf948ad894cda10897 80955df4218f497199cae4bea85c053d 52d9e2a44a3d400ca65cd306006347a1 Y b814c1375c0d4b45ac962966e53440b6--52d9e2a44a3d400ca65cd306006347a1 478f6eca27e241fa907777e75d488b27 2 e9dead11bfa74807b3dbbad01b7f4b93 52d9e2a44a3d400ca65cd306006347a1--e9dead11bfa74807b3dbbad01b7f4b93 39ebdf1f7489478ea711f8da1b2a6488 HamEvo e9dead11bfa74807b3dbbad01b7f4b93--39ebdf1f7489478ea711f8da1b2a6488 39ebdf1f7489478ea711f8da1b2a6488--80955df4218f497199cae4bea85c053d d538f1e6f04d4e52b0cc63e9b8059e1c d1cb2841735746748241ab567359d6d0 RX(x) 478f6eca27e241fa907777e75d488b27--d1cb2841735746748241ab567359d6d0 6a89f1a731334df1bfb5e592292aa7d3 3 2f621c16bb4343f4ba612a1543be549b d1cb2841735746748241ab567359d6d0--2f621c16bb4343f4ba612a1543be549b 4e86d7fc03eb402ea5e03c3fbcd03b0d t = 10 2f621c16bb4343f4ba612a1543be549b--4e86d7fc03eb402ea5e03c3fbcd03b0d 4e86d7fc03eb402ea5e03c3fbcd03b0d--d538f1e6f04d4e52b0cc63e9b8059e1c 06c87cfd3a394edcb901f88354f57046 344874be8ab841a3ae783d51d1521de1 RX(0.5) 6a89f1a731334df1bfb5e592292aa7d3--344874be8ab841a3ae783d51d1521de1 faaab1e551454b6da9a169bae45d3876 X 344874be8ab841a3ae783d51d1521de1--faaab1e551454b6da9a169bae45d3876 faaab1e551454b6da9a169bae45d3876--2f621c16bb4343f4ba612a1543be549b 9f5d83712f954cd0a28b0cdd58f02645 faaab1e551454b6da9a169bae45d3876--9f5d83712f954cd0a28b0cdd58f02645 9f5d83712f954cd0a28b0cdd58f02645--06c87cfd3a394edcb901f88354f57046
from qadence import feature_map, hea, chain

block = chain(feature_map(4, reupload_scaling="Tower"), hea(4,2))
%3 cluster_2e393558a05b4bd0aa744d59cc7bb4e6 HEA cluster_7b6061e223cd49379c2e5ed7dc884312 Tower Fourier FM 4cc6ab2d376c4744893d901cc05a6c69 0 b414a0b8eec14fd69893a3f60bc8262c RX(1.0*phi) 4cc6ab2d376c4744893d901cc05a6c69--b414a0b8eec14fd69893a3f60bc8262c 1ec90a471d19470db0d650a03094033e 1 11e6bf52dac24ed9824479e0bd826d16 RX(theta₀) b414a0b8eec14fd69893a3f60bc8262c--11e6bf52dac24ed9824479e0bd826d16 53a4205a603a4ef0bf8bcc057b492953 RY(theta₄) 11e6bf52dac24ed9824479e0bd826d16--53a4205a603a4ef0bf8bcc057b492953 84f41ee11cac4b6284c499081bb8458f RX(theta₈) 53a4205a603a4ef0bf8bcc057b492953--84f41ee11cac4b6284c499081bb8458f 21cf64c374c545b4a6b109df53eb4fd4 84f41ee11cac4b6284c499081bb8458f--21cf64c374c545b4a6b109df53eb4fd4 78bff9a3dffc41fdbe499996812833fe 21cf64c374c545b4a6b109df53eb4fd4--78bff9a3dffc41fdbe499996812833fe 0d6e4c98f0f34a30af6ee90aea7780dc RX(theta₁₂) 78bff9a3dffc41fdbe499996812833fe--0d6e4c98f0f34a30af6ee90aea7780dc efcd91496663477a83317a610d907056 RY(theta₁₆) 0d6e4c98f0f34a30af6ee90aea7780dc--efcd91496663477a83317a610d907056 f0c173e4da164f249af88ff2f6d338c2 RX(theta₂₀) efcd91496663477a83317a610d907056--f0c173e4da164f249af88ff2f6d338c2 04c97e53ded04ed1a0567b9da7d5462f f0c173e4da164f249af88ff2f6d338c2--04c97e53ded04ed1a0567b9da7d5462f caa2f582aaa8457e93401f10e3d22cbb 04c97e53ded04ed1a0567b9da7d5462f--caa2f582aaa8457e93401f10e3d22cbb 98f3c6f37716486d8353a86e9c48e18e caa2f582aaa8457e93401f10e3d22cbb--98f3c6f37716486d8353a86e9c48e18e 1591f015de074bf495305aaf58d0692e 50e40648be0a4b168ad2b2fc9d81ea7a RX(2.0*phi) 1ec90a471d19470db0d650a03094033e--50e40648be0a4b168ad2b2fc9d81ea7a e67473f12ecd48f1a968db8fdd6504e1 2 cbc100f5a35b4496b3808eea5874d2eb RX(theta₁) 50e40648be0a4b168ad2b2fc9d81ea7a--cbc100f5a35b4496b3808eea5874d2eb 6b5d894565524f1681c60416a44dd011 RY(theta₅) cbc100f5a35b4496b3808eea5874d2eb--6b5d894565524f1681c60416a44dd011 3db821c9979f44a3b698f0bf66aaf0d0 RX(theta₉) 6b5d894565524f1681c60416a44dd011--3db821c9979f44a3b698f0bf66aaf0d0 ec57777ee2354de5b0fa0fb4ec5e00ea X 3db821c9979f44a3b698f0bf66aaf0d0--ec57777ee2354de5b0fa0fb4ec5e00ea ec57777ee2354de5b0fa0fb4ec5e00ea--21cf64c374c545b4a6b109df53eb4fd4 4895997b0e7d4372991656603bc9e21d ec57777ee2354de5b0fa0fb4ec5e00ea--4895997b0e7d4372991656603bc9e21d 3076a1f0b5a8412295c2a3e4c6bfefb7 RX(theta₁₃) 4895997b0e7d4372991656603bc9e21d--3076a1f0b5a8412295c2a3e4c6bfefb7 81da2af5886842c6827718087ccf4c96 RY(theta₁₇) 3076a1f0b5a8412295c2a3e4c6bfefb7--81da2af5886842c6827718087ccf4c96 fd27f4f3b2f44a19a225b473eeb0b841 RX(theta₂₁) 81da2af5886842c6827718087ccf4c96--fd27f4f3b2f44a19a225b473eeb0b841 7aa6d4f441fe436d8f2f928b7fd47f56 X fd27f4f3b2f44a19a225b473eeb0b841--7aa6d4f441fe436d8f2f928b7fd47f56 7aa6d4f441fe436d8f2f928b7fd47f56--04c97e53ded04ed1a0567b9da7d5462f 81a3662dbfd7468980a6d6d80c60e32b 7aa6d4f441fe436d8f2f928b7fd47f56--81a3662dbfd7468980a6d6d80c60e32b 81a3662dbfd7468980a6d6d80c60e32b--1591f015de074bf495305aaf58d0692e 3205249bb0a14622a2676950ed3590b1 d92043596c8f4471b54c33df59e51472 RX(3.0*phi) e67473f12ecd48f1a968db8fdd6504e1--d92043596c8f4471b54c33df59e51472 777d9792c1204f059dd5604e9bb6d657 3 2b8a79ba10a64c6087988b0416a30d87 RX(theta₂) d92043596c8f4471b54c33df59e51472--2b8a79ba10a64c6087988b0416a30d87 517b59b1b8164bccb7a4cda535ae2498 RY(theta₆) 2b8a79ba10a64c6087988b0416a30d87--517b59b1b8164bccb7a4cda535ae2498 6f0549abda284fe0877464e363d404f8 RX(theta₁₀) 517b59b1b8164bccb7a4cda535ae2498--6f0549abda284fe0877464e363d404f8 414b1a28770f4e4d81f2991984660ca2 6f0549abda284fe0877464e363d404f8--414b1a28770f4e4d81f2991984660ca2 1c92ac3396204f408c9d9d776f60f3ad X 414b1a28770f4e4d81f2991984660ca2--1c92ac3396204f408c9d9d776f60f3ad 1c92ac3396204f408c9d9d776f60f3ad--4895997b0e7d4372991656603bc9e21d 5ce1abccfc4e4945ae50e1a6434d014e RX(theta₁₄) 1c92ac3396204f408c9d9d776f60f3ad--5ce1abccfc4e4945ae50e1a6434d014e 8f3cc397a065443bb8281fad8b1ad033 RY(theta₁₈) 5ce1abccfc4e4945ae50e1a6434d014e--8f3cc397a065443bb8281fad8b1ad033 24b4be28154845a2a96adbf274e916fd RX(theta₂₂) 8f3cc397a065443bb8281fad8b1ad033--24b4be28154845a2a96adbf274e916fd 94e4ed7df2f24758bfca0fd49941a859 24b4be28154845a2a96adbf274e916fd--94e4ed7df2f24758bfca0fd49941a859 6aa642824d33452d8704ba240d57bbba X 94e4ed7df2f24758bfca0fd49941a859--6aa642824d33452d8704ba240d57bbba 6aa642824d33452d8704ba240d57bbba--81a3662dbfd7468980a6d6d80c60e32b 6aa642824d33452d8704ba240d57bbba--3205249bb0a14622a2676950ed3590b1 7e7d8cfd97094696820967b81be93a05 1b247b4f9faf46c3bc544858d7740b02 RX(4.0*phi) 777d9792c1204f059dd5604e9bb6d657--1b247b4f9faf46c3bc544858d7740b02 b0b2c50f3e4c4850979605d5e792a248 RX(theta₃) 1b247b4f9faf46c3bc544858d7740b02--b0b2c50f3e4c4850979605d5e792a248 3aa708f8d8054b4895b99899e3e56312 RY(theta₇) b0b2c50f3e4c4850979605d5e792a248--3aa708f8d8054b4895b99899e3e56312 359edeb319234528bb18a92a783eed11 RX(theta₁₁) 3aa708f8d8054b4895b99899e3e56312--359edeb319234528bb18a92a783eed11 6cdb6da438934073a8de6e17d55899ac X 359edeb319234528bb18a92a783eed11--6cdb6da438934073a8de6e17d55899ac 6cdb6da438934073a8de6e17d55899ac--414b1a28770f4e4d81f2991984660ca2 836cfe518e0a43069452747d5c7ee355 6cdb6da438934073a8de6e17d55899ac--836cfe518e0a43069452747d5c7ee355 231738034e214cd8b8112c29eed17228 RX(theta₁₅) 836cfe518e0a43069452747d5c7ee355--231738034e214cd8b8112c29eed17228 677f74f8c9b7452e981af331074a421d RY(theta₁₉) 231738034e214cd8b8112c29eed17228--677f74f8c9b7452e981af331074a421d 5d7b66ab48be4a9593019a0fd4719ffe RX(theta₂₃) 677f74f8c9b7452e981af331074a421d--5d7b66ab48be4a9593019a0fd4719ffe b3340de9be074dc8a0cabc64000b84ca X 5d7b66ab48be4a9593019a0fd4719ffe--b3340de9be074dc8a0cabc64000b84ca b3340de9be074dc8a0cabc64000b84ca--94e4ed7df2f24758bfca0fd49941a859 e7f9f288a0a4420d8557e5cbc42405e8 b3340de9be074dc8a0cabc64000b84ca--e7f9f288a0a4420d8557e5cbc42405e8 e7f9f288a0a4420d8557e5cbc42405e8--7e7d8cfd97094696820967b81be93a05
from qadence import QuantumModel, QuantumCircuit, total_magnetization, hea

model = QuantumModel(QuantumCircuit(3, hea(3,2)), total_magnetization(3))
%3 cluster_977fda448ab24f6ca468bae8c1143a5f Obs. cluster_9d87b97107f64b8fa92a73690c6de09c cluster_60b5ae15f7874c759e87cb2c061deebe HEA 5dd7d13e45fe41658fa6081840ceadf9 0 a6669f974c6f47d287b5a891458524e3 RX(theta₀) 5dd7d13e45fe41658fa6081840ceadf9--a6669f974c6f47d287b5a891458524e3 abd4ad8b7443405db45ecfe937b73020 1 7b3379af03124bc2acdc7c750c2bfacf RY(theta₃) a6669f974c6f47d287b5a891458524e3--7b3379af03124bc2acdc7c750c2bfacf 85b8f029b4b6410d901fdf4562222667 RX(theta₆) 7b3379af03124bc2acdc7c750c2bfacf--85b8f029b4b6410d901fdf4562222667 ac85395ac278468ca3b334fdd12151cd 85b8f029b4b6410d901fdf4562222667--ac85395ac278468ca3b334fdd12151cd 54fe7b72c26c4e32ad8177c03cb91a98 ac85395ac278468ca3b334fdd12151cd--54fe7b72c26c4e32ad8177c03cb91a98 c0020b2f58244e17a34622c00ff641f8 RX(theta₉) 54fe7b72c26c4e32ad8177c03cb91a98--c0020b2f58244e17a34622c00ff641f8 a7905c106d904d3592bbe4214da10eea RY(theta₁₂) c0020b2f58244e17a34622c00ff641f8--a7905c106d904d3592bbe4214da10eea 92b9480fbc53473a8b78e7b43555bc13 RX(theta₁₅) a7905c106d904d3592bbe4214da10eea--92b9480fbc53473a8b78e7b43555bc13 d7b2be8df6264ad59abba32920703c82 92b9480fbc53473a8b78e7b43555bc13--d7b2be8df6264ad59abba32920703c82 b689df98d53f41e79a71379a44252f80 d7b2be8df6264ad59abba32920703c82--b689df98d53f41e79a71379a44252f80 8143d2dc3ecc4380ac8bb8a4760fcfbd b689df98d53f41e79a71379a44252f80--8143d2dc3ecc4380ac8bb8a4760fcfbd 94b65ec2c95b4ab58b2eef06deddeeda 8143d2dc3ecc4380ac8bb8a4760fcfbd--94b65ec2c95b4ab58b2eef06deddeeda 67ec2fccb68046419e357620728359f0 80811cc274e34cbaa9ef686f8cfbc7c9 RX(theta₁) abd4ad8b7443405db45ecfe937b73020--80811cc274e34cbaa9ef686f8cfbc7c9 4e306896d33b4b4494f2cf338d8bc160 2 e07412fa57ff4e9197489d437aaeef3a RY(theta₄) 80811cc274e34cbaa9ef686f8cfbc7c9--e07412fa57ff4e9197489d437aaeef3a ed3a76b3db05494999d23e848e6314f1 RX(theta₇) e07412fa57ff4e9197489d437aaeef3a--ed3a76b3db05494999d23e848e6314f1 e4fba8360b96448f8d216f38d6fb1139 X ed3a76b3db05494999d23e848e6314f1--e4fba8360b96448f8d216f38d6fb1139 e4fba8360b96448f8d216f38d6fb1139--ac85395ac278468ca3b334fdd12151cd abca6842682a436797ef545763a5b30a e4fba8360b96448f8d216f38d6fb1139--abca6842682a436797ef545763a5b30a fa8a8a88974544f4ad42b4c0b4b0371f RX(theta₁₀) abca6842682a436797ef545763a5b30a--fa8a8a88974544f4ad42b4c0b4b0371f 5c4c5d6140ec40eba4b950c1d2377ffa RY(theta₁₃) fa8a8a88974544f4ad42b4c0b4b0371f--5c4c5d6140ec40eba4b950c1d2377ffa ea754725f9be4282b7d07a10eeebbf95 RX(theta₁₆) 5c4c5d6140ec40eba4b950c1d2377ffa--ea754725f9be4282b7d07a10eeebbf95 01d1ec342bff4c7eb99f170e029edfac X ea754725f9be4282b7d07a10eeebbf95--01d1ec342bff4c7eb99f170e029edfac 01d1ec342bff4c7eb99f170e029edfac--d7b2be8df6264ad59abba32920703c82 5cbad5887b9c450e91d6120c5f894e85 01d1ec342bff4c7eb99f170e029edfac--5cbad5887b9c450e91d6120c5f894e85 4a3a134220f64fd4af01d7968635a0b5 AddBlock 5cbad5887b9c450e91d6120c5f894e85--4a3a134220f64fd4af01d7968635a0b5 4a3a134220f64fd4af01d7968635a0b5--67ec2fccb68046419e357620728359f0 783aab37745243189ce051ec4f591553 e88685697b8147bc82e22d999e2af447 RX(theta₂) 4e306896d33b4b4494f2cf338d8bc160--e88685697b8147bc82e22d999e2af447 27c92c4741f249b2ac2adb879dc2e8fb RY(theta₅) e88685697b8147bc82e22d999e2af447--27c92c4741f249b2ac2adb879dc2e8fb 9c02fd7e64914071a55e8983ad3ef999 RX(theta₈) 27c92c4741f249b2ac2adb879dc2e8fb--9c02fd7e64914071a55e8983ad3ef999 387ca737028e450c941b37b7648b8913 9c02fd7e64914071a55e8983ad3ef999--387ca737028e450c941b37b7648b8913 7f724e016ad64a8687c8f96a27dff84f X 387ca737028e450c941b37b7648b8913--7f724e016ad64a8687c8f96a27dff84f 7f724e016ad64a8687c8f96a27dff84f--abca6842682a436797ef545763a5b30a cef0f8876e3c442384af3b3aaf9b7a8a RX(theta₁₁) 7f724e016ad64a8687c8f96a27dff84f--cef0f8876e3c442384af3b3aaf9b7a8a be8b2fcd97f44ec88d351759dcb99378 RY(theta₁₄) cef0f8876e3c442384af3b3aaf9b7a8a--be8b2fcd97f44ec88d351759dcb99378 655483573378484996540310fe52eb76 RX(theta₁₇) be8b2fcd97f44ec88d351759dcb99378--655483573378484996540310fe52eb76 9e8d16da2c5f4499874a654646484de6 655483573378484996540310fe52eb76--9e8d16da2c5f4499874a654646484de6 bc16e8c1a22e415d9fc4822058a0541d X 9e8d16da2c5f4499874a654646484de6--bc16e8c1a22e415d9fc4822058a0541d bc16e8c1a22e415d9fc4822058a0541d--5cbad5887b9c450e91d6120c5f894e85 3ad5bc9cfbbc4dbf970ca4f7012721d0 bc16e8c1a22e415d9fc4822058a0541d--3ad5bc9cfbbc4dbf970ca4f7012721d0 3ad5bc9cfbbc4dbf970ca4f7012721d0--783aab37745243189ce051ec4f591553
from qadence import *

b = chain(SWAP(0,1), SWAP(0,3))
%3 e6912133a57f4dd685ca5ab99d0a8893 0 4b83248682124915b1957d568f4b4ef1 e6912133a57f4dd685ca5ab99d0a8893--4b83248682124915b1957d568f4b4ef1 0141e2a5cae1491ba42a6b4abc9d5436 1 d7530ba9ece541e79905c36e01b91650 8eb66d160fe2424182e267fc3477ca5c 4b83248682124915b1957d568f4b4ef1--8eb66d160fe2424182e267fc3477ca5c 7368afc42e0042088b89510b2d72e7f2 d7530ba9ece541e79905c36e01b91650--7368afc42e0042088b89510b2d72e7f2 24d330a60cb64b35a877a0eeba418d8f a363675e247947ea88861ae7a8569691 7368afc42e0042088b89510b2d72e7f2--a363675e247947ea88861ae7a8569691 3e34bcd61c584549a0a7698c9beca92e 24d330a60cb64b35a877a0eeba418d8f--3e34bcd61c584549a0a7698c9beca92e 588276ee4c7b467794178f878b56ff7a ba709525f0214073a3df051ffd7621c2 0141e2a5cae1491ba42a6b4abc9d5436--ba709525f0214073a3df051ffd7621c2 bfe636a01c044295a5b779e9b5cefb51 2 ba709525f0214073a3df051ffd7621c2--d7530ba9ece541e79905c36e01b91650 19e06970472f4ef2ad472e078b145b42 8eb66d160fe2424182e267fc3477ca5c--19e06970472f4ef2ad472e078b145b42 250724baeaf44f4ead7ea7e0429d77a5 19e06970472f4ef2ad472e078b145b42--250724baeaf44f4ead7ea7e0429d77a5 250724baeaf44f4ead7ea7e0429d77a5--588276ee4c7b467794178f878b56ff7a aee0895156474d168db7cb2a24e0e979 9e5ff98fdb4c4ac79afc415d74078e2c bfe636a01c044295a5b779e9b5cefb51--9e5ff98fdb4c4ac79afc415d74078e2c d26fe4b6ebd8436bb8f243c9f8bfbe17 3 7e3e61f7425a48f2a4270400c2505f33 9e5ff98fdb4c4ac79afc415d74078e2c--7e3e61f7425a48f2a4270400c2505f33 745f6f28701f4257aabe14f47b6b0fa3 7e3e61f7425a48f2a4270400c2505f33--745f6f28701f4257aabe14f47b6b0fa3 761a7a7a205746c39c2ec641c7845263 745f6f28701f4257aabe14f47b6b0fa3--761a7a7a205746c39c2ec641c7845263 761a7a7a205746c39c2ec641c7845263--aee0895156474d168db7cb2a24e0e979 65d243edbc0b467c9c04a6709f46029d 42209cd4562540ada0b729f7748e2ad6 d26fe4b6ebd8436bb8f243c9f8bfbe17--42209cd4562540ada0b729f7748e2ad6 46056d8c4cc743bd8cffa80fbb7795a4 42209cd4562540ada0b729f7748e2ad6--46056d8c4cc743bd8cffa80fbb7795a4 3a98c336255b405190cdadae0656a7f5 46056d8c4cc743bd8cffa80fbb7795a4--3a98c336255b405190cdadae0656a7f5 3a98c336255b405190cdadae0656a7f5--24d330a60cb64b35a877a0eeba418d8f a363675e247947ea88861ae7a8569691--65d243edbc0b467c9c04a6709f46029d
from qadence import *

b = chain(CPHASE(0, 1, 0.5), CPHASE(0, 2, 0.5), CPHASE(0, 3, 0.5))
%3 d2c967a8ab51497e95753a5d9f8baccd 0 54d73417fe2d433eb4bd05a5154039c0 d2c967a8ab51497e95753a5d9f8baccd--54d73417fe2d433eb4bd05a5154039c0 7dff1eb1ff4e4e64b916a3a3b69a0086 1 10d778dafdf8444d8de71e77318b3466 54d73417fe2d433eb4bd05a5154039c0--10d778dafdf8444d8de71e77318b3466 c114eee78eca4564a7aaee7c66e096db 10d778dafdf8444d8de71e77318b3466--c114eee78eca4564a7aaee7c66e096db ff39368c4c414580899e4fb8b0ea454e c114eee78eca4564a7aaee7c66e096db--ff39368c4c414580899e4fb8b0ea454e dbea12f6a6ac48b89e90fd09b12a49ac 7b3988ca80484134a5a99a9854d1787a PHASE(0.5) 7dff1eb1ff4e4e64b916a3a3b69a0086--7b3988ca80484134a5a99a9854d1787a e5e3db4da0fa4c198c443eec0542b19a 2 7b3988ca80484134a5a99a9854d1787a--54d73417fe2d433eb4bd05a5154039c0 7532335263e54b3f8db8a7f844d8dde1 7b3988ca80484134a5a99a9854d1787a--7532335263e54b3f8db8a7f844d8dde1 6d6b44299e4241b6985fd662bc880652 7532335263e54b3f8db8a7f844d8dde1--6d6b44299e4241b6985fd662bc880652 6d6b44299e4241b6985fd662bc880652--dbea12f6a6ac48b89e90fd09b12a49ac 8e14da55c04148e88ef38259fdd77ed8 07fa4c247f084210ad220105028156d5 e5e3db4da0fa4c198c443eec0542b19a--07fa4c247f084210ad220105028156d5 780c6c7d7fda4462ac7e86a309aa07ab 3 c6119a3ee3ca41c385f3f6dae961ea5d PHASE(0.5) 07fa4c247f084210ad220105028156d5--c6119a3ee3ca41c385f3f6dae961ea5d c6119a3ee3ca41c385f3f6dae961ea5d--10d778dafdf8444d8de71e77318b3466 773ee19fb5464ae2a006c00d37662034 c6119a3ee3ca41c385f3f6dae961ea5d--773ee19fb5464ae2a006c00d37662034 773ee19fb5464ae2a006c00d37662034--8e14da55c04148e88ef38259fdd77ed8 9ed26a7877104d388aa6023b2c99cd59 bc7ba9305f8e473295d56aac59a7668e 780c6c7d7fda4462ac7e86a309aa07ab--bc7ba9305f8e473295d56aac59a7668e 4e30b33387644fdabb6c3ca0faf8ff20 bc7ba9305f8e473295d56aac59a7668e--4e30b33387644fdabb6c3ca0faf8ff20 833b509be8c340b2abfaa8e8dce40a58 PHASE(0.5) 4e30b33387644fdabb6c3ca0faf8ff20--833b509be8c340b2abfaa8e8dce40a58 833b509be8c340b2abfaa8e8dce40a58--c114eee78eca4564a7aaee7c66e096db 833b509be8c340b2abfaa8e8dce40a58--9ed26a7877104d388aa6023b2c99cd59

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