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
c1c0450488d94afda8a5f96433f44c52
0
85ed3ec0bc5e4defbff9476bdc8b877f
X
c1c0450488d94afda8a5f96433f44c52--85ed3ec0bc5e4defbff9476bdc8b877f
8d420e80fd4a436a859db68f40ffbf85
1
a2eb92445af5414ea8e562cd77135711
85ed3ec0bc5e4defbff9476bdc8b877f--a2eb92445af5414ea8e562cd77135711
7596b60b84f940adb3440c29c7e5030a
b5f33648a96b43a3b62fa6445202a3cf
Y
8d420e80fd4a436a859db68f40ffbf85--b5f33648a96b43a3b62fa6445202a3cf
b5f33648a96b43a3b62fa6445202a3cf--7596b60b84f940adb3440c29c7e5030a
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
2400bbf8ac964b9198b375bc31bdc80a
0
6b60c35689424566a32789230e010283
X
2400bbf8ac964b9198b375bc31bdc80a--6b60c35689424566a32789230e010283
9f678920498545bca57a01673573814f
Y
6b60c35689424566a32789230e010283--9f678920498545bca57a01673573814f
d3cf381a2d974c8490165fa0d51519ea
9f678920498545bca57a01673573814f--d3cf381a2d974c8490165fa0d51519ea
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
bc8f073db2e74a7fbb33443a00cef3f5
0
495ee3baa8574c388d9c04e954bd9f99
X
bc8f073db2e74a7fbb33443a00cef3f5--495ee3baa8574c388d9c04e954bd9f99
e3c2df85f4bd43218fa93d97afd7d6fe
1
c81e8747a2464743a9030e9200122795
495ee3baa8574c388d9c04e954bd9f99--c81e8747a2464743a9030e9200122795
5e43099bfa544338964d8c8f0dd81d97
c81e8747a2464743a9030e9200122795--5e43099bfa544338964d8c8f0dd81d97
05b9910665d2427fb2d80c4acbda5f7f
80a3e95d6f9e4ae0a45cef092acb93b7
e3c2df85f4bd43218fa93d97afd7d6fe--80a3e95d6f9e4ae0a45cef092acb93b7
fb5721465a534ca1978b01eb3550d76f
Y
80a3e95d6f9e4ae0a45cef092acb93b7--fb5721465a534ca1978b01eb3550d76f
fb5721465a534ca1978b01eb3550d76f--05b9910665d2427fb2d80c4acbda5f7f
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_d4759d7b6b964d5aa8a9825a05497a47
c1b10b4fc99d45bfb745e2d0d4309253
0
c969e2754cd845899f655b43fe5f6f8e
c1b10b4fc99d45bfb745e2d0d4309253--c969e2754cd845899f655b43fe5f6f8e
a4badef2d70f4736bb2faad53fab42fe
1
0b598c0f843448be9b6b315c5503b7fb
c969e2754cd845899f655b43fe5f6f8e--0b598c0f843448be9b6b315c5503b7fb
55653f2d0e7f45fa80c27c9bfc3c431c
2f122e7406be4ff390cd19be0f56b86f
AddBlock
a4badef2d70f4736bb2faad53fab42fe--2f122e7406be4ff390cd19be0f56b86f
c4165eb3a0184bcabdd6e2dcd24eda8a
2
2f122e7406be4ff390cd19be0f56b86f--55653f2d0e7f45fa80c27c9bfc3c431c
f6a989352d2e4d2c9735ffe71c467208
e7f7564acb6f4bf8886ba34e43894dee
c4165eb3a0184bcabdd6e2dcd24eda8a--e7f7564acb6f4bf8886ba34e43894dee
e7f7564acb6f4bf8886ba34e43894dee--f6a989352d2e4d2c9735ffe71c467208
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_52095309a61e42dbae92d094cc6db998
cluster_6eef15536d58470f87962f143c8c0219
rx
52f6bb8efc534def95bf9b3d287fc025
0
df766b681a774bd1bd11a4fb2158c617
X
52f6bb8efc534def95bf9b3d287fc025--df766b681a774bd1bd11a4fb2158c617
a7f4bca6e8a748a1bae66d456c186985
1
65177a72f53d4804a766397eb4222983
df766b681a774bd1bd11a4fb2158c617--65177a72f53d4804a766397eb4222983
0c410b5e735f4e92b18d029d4b0b94d2
65177a72f53d4804a766397eb4222983--0c410b5e735f4e92b18d029d4b0b94d2
6bbd87be54064e56b9dc3c9825c1b476
0c410b5e735f4e92b18d029d4b0b94d2--6bbd87be54064e56b9dc3c9825c1b476
0c9efaf3393b45008b907708da272d6b
7f208d684f4c4544af80b28d5cce05c3
Y
a7f4bca6e8a748a1bae66d456c186985--7f208d684f4c4544af80b28d5cce05c3
171f9d5787174f5d993d0f8666d2a31f
2
e8f0a7a255b343ddbe30b821ad24106e
7f208d684f4c4544af80b28d5cce05c3--e8f0a7a255b343ddbe30b821ad24106e
9cf22bb0e45d43fd8b26dd05c248bdd8
HamEvo
e8f0a7a255b343ddbe30b821ad24106e--9cf22bb0e45d43fd8b26dd05c248bdd8
9cf22bb0e45d43fd8b26dd05c248bdd8--0c9efaf3393b45008b907708da272d6b
53517c910ba042b1b83adddd5fb42550
58b8554cb60c4038a7e7bb9596b35d31
RX(x)
171f9d5787174f5d993d0f8666d2a31f--58b8554cb60c4038a7e7bb9596b35d31
2d63f8694bd047e1a2f84bf07fad8a86
3
405dd2b490d24a9bb2bd0da958d05e2d
58b8554cb60c4038a7e7bb9596b35d31--405dd2b490d24a9bb2bd0da958d05e2d
97b3db5eed5b4d82b22e236c6ad49a7e
t = 10
405dd2b490d24a9bb2bd0da958d05e2d--97b3db5eed5b4d82b22e236c6ad49a7e
97b3db5eed5b4d82b22e236c6ad49a7e--53517c910ba042b1b83adddd5fb42550
be7dd8d938f04e74a202a49bab93fbe8
e7c6251cbec04398b740030b06332d60
RX(0.5)
2d63f8694bd047e1a2f84bf07fad8a86--e7c6251cbec04398b740030b06332d60
40f8eaed13594885a7b8a0796eee1751
X
e7c6251cbec04398b740030b06332d60--40f8eaed13594885a7b8a0796eee1751
40f8eaed13594885a7b8a0796eee1751--405dd2b490d24a9bb2bd0da958d05e2d
810f612b086b47d0bea44648bd1d4a9a
40f8eaed13594885a7b8a0796eee1751--810f612b086b47d0bea44648bd1d4a9a
810f612b086b47d0bea44648bd1d4a9a--be7dd8d938f04e74a202a49bab93fbe8
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_b749bc9cec2e4ef5a1153167d0df329a
HEA
cluster_2496c757bcc84d27aa1d55e5ccce34f8
Tower Fourier FM
1de943665fea4977a6d16fed322468d0
0
76dc10e595274772ad5a3a62d6d930d0
RX(1.0*phi)
1de943665fea4977a6d16fed322468d0--76dc10e595274772ad5a3a62d6d930d0
6f4f833f63ab4201985483f00f8c7502
1
ab6c6b82a99c4c00b9bbb27c5a835334
RX(theta₀)
76dc10e595274772ad5a3a62d6d930d0--ab6c6b82a99c4c00b9bbb27c5a835334
e03d3f2f55d4418bb1e3e82610aafccc
RY(theta₄)
ab6c6b82a99c4c00b9bbb27c5a835334--e03d3f2f55d4418bb1e3e82610aafccc
764c8a05254a46b8ba69972b41922c3e
RX(theta₈)
e03d3f2f55d4418bb1e3e82610aafccc--764c8a05254a46b8ba69972b41922c3e
df03089fedff4235b48cd362af9ffc56
764c8a05254a46b8ba69972b41922c3e--df03089fedff4235b48cd362af9ffc56
1138b7aab0f9419e9ba30d709b30c556
df03089fedff4235b48cd362af9ffc56--1138b7aab0f9419e9ba30d709b30c556
afd12a85a48643c589b49af0168d1733
RX(theta₁₂)
1138b7aab0f9419e9ba30d709b30c556--afd12a85a48643c589b49af0168d1733
9356fde68a33483f9000679e8a8b2234
RY(theta₁₆)
afd12a85a48643c589b49af0168d1733--9356fde68a33483f9000679e8a8b2234
257d4c99f6a243868d9c61966b149728
RX(theta₂₀)
9356fde68a33483f9000679e8a8b2234--257d4c99f6a243868d9c61966b149728
51d516c8e8ab492388aca41cbf978726
257d4c99f6a243868d9c61966b149728--51d516c8e8ab492388aca41cbf978726
0ebe08bd475245d0adf20b084394197d
51d516c8e8ab492388aca41cbf978726--0ebe08bd475245d0adf20b084394197d
dc5a275c7f274642a7a4de671999b1d1
0ebe08bd475245d0adf20b084394197d--dc5a275c7f274642a7a4de671999b1d1
a6dca4af1ec14ab893baf58a78c03d7b
6c983c7220834993a03766e24075772f
RX(2.0*phi)
6f4f833f63ab4201985483f00f8c7502--6c983c7220834993a03766e24075772f
4693be01dc4942748dcde7f63e8cc770
2
2ef0b4400cbc438881a92f5833daf7f1
RX(theta₁)
6c983c7220834993a03766e24075772f--2ef0b4400cbc438881a92f5833daf7f1
146ffd4d96ad43f0a8864c2e563cbac1
RY(theta₅)
2ef0b4400cbc438881a92f5833daf7f1--146ffd4d96ad43f0a8864c2e563cbac1
5068c25d0bf24b6f98efa6a2e7dd61b9
RX(theta₉)
146ffd4d96ad43f0a8864c2e563cbac1--5068c25d0bf24b6f98efa6a2e7dd61b9
7efe0481aac14befb46779cc261c1a2f
X
5068c25d0bf24b6f98efa6a2e7dd61b9--7efe0481aac14befb46779cc261c1a2f
7efe0481aac14befb46779cc261c1a2f--df03089fedff4235b48cd362af9ffc56
9da44c835263430b9a8366d95258e423
7efe0481aac14befb46779cc261c1a2f--9da44c835263430b9a8366d95258e423
62e27a84ebf045159b53274f47fa1312
RX(theta₁₃)
9da44c835263430b9a8366d95258e423--62e27a84ebf045159b53274f47fa1312
c943c925943446d594bddbc7e00e6916
RY(theta₁₇)
62e27a84ebf045159b53274f47fa1312--c943c925943446d594bddbc7e00e6916
33d76ea5372d413ba97e3a6a59470c7a
RX(theta₂₁)
c943c925943446d594bddbc7e00e6916--33d76ea5372d413ba97e3a6a59470c7a
79f1f076149b4633b3b4ca98f0caf4e0
X
33d76ea5372d413ba97e3a6a59470c7a--79f1f076149b4633b3b4ca98f0caf4e0
79f1f076149b4633b3b4ca98f0caf4e0--51d516c8e8ab492388aca41cbf978726
06041959c5e0414aa1fb674c62a3a0ec
79f1f076149b4633b3b4ca98f0caf4e0--06041959c5e0414aa1fb674c62a3a0ec
06041959c5e0414aa1fb674c62a3a0ec--a6dca4af1ec14ab893baf58a78c03d7b
bb6336cbcee0451ea5c7fddf30c34e56
47f22efdb4584ac289212d13d5dfd7f4
RX(3.0*phi)
4693be01dc4942748dcde7f63e8cc770--47f22efdb4584ac289212d13d5dfd7f4
9b9e28710fb14aab96f5fc0591b88c7c
3
fde109ff7d664993a30d1059ec43347c
RX(theta₂)
47f22efdb4584ac289212d13d5dfd7f4--fde109ff7d664993a30d1059ec43347c
6fd814ea88b9476aa0b00d1ffd0212e8
RY(theta₆)
fde109ff7d664993a30d1059ec43347c--6fd814ea88b9476aa0b00d1ffd0212e8
e82563cf88264d56ad403b7ac53cba2e
RX(theta₁₀)
6fd814ea88b9476aa0b00d1ffd0212e8--e82563cf88264d56ad403b7ac53cba2e
165a4e83d32f44eea431c90444f648f9
e82563cf88264d56ad403b7ac53cba2e--165a4e83d32f44eea431c90444f648f9
d195498195b644bd94cc89393e81ba46
X
165a4e83d32f44eea431c90444f648f9--d195498195b644bd94cc89393e81ba46
d195498195b644bd94cc89393e81ba46--9da44c835263430b9a8366d95258e423
e758599083d048b58cc76a7523887c6c
RX(theta₁₄)
d195498195b644bd94cc89393e81ba46--e758599083d048b58cc76a7523887c6c
e33776c4294c4f12ba0ff42dd72a82c4
RY(theta₁₈)
e758599083d048b58cc76a7523887c6c--e33776c4294c4f12ba0ff42dd72a82c4
363f5a10425449de845d55ea04ea1c89
RX(theta₂₂)
e33776c4294c4f12ba0ff42dd72a82c4--363f5a10425449de845d55ea04ea1c89
7f55a730e1304adca41b62a9bfce6371
363f5a10425449de845d55ea04ea1c89--7f55a730e1304adca41b62a9bfce6371
a9b5c7ccaabd4e67a3d7cce97aa61e2a
X
7f55a730e1304adca41b62a9bfce6371--a9b5c7ccaabd4e67a3d7cce97aa61e2a
a9b5c7ccaabd4e67a3d7cce97aa61e2a--06041959c5e0414aa1fb674c62a3a0ec
a9b5c7ccaabd4e67a3d7cce97aa61e2a--bb6336cbcee0451ea5c7fddf30c34e56
ff452fe4b116431d96be659735625d91
ea61af70bb674480ba01b8499bd0d3ef
RX(4.0*phi)
9b9e28710fb14aab96f5fc0591b88c7c--ea61af70bb674480ba01b8499bd0d3ef
cf5f716bddd647cba9c081685ab2f447
RX(theta₃)
ea61af70bb674480ba01b8499bd0d3ef--cf5f716bddd647cba9c081685ab2f447
46844216c28942a1ac5fc9f021da17a2
RY(theta₇)
cf5f716bddd647cba9c081685ab2f447--46844216c28942a1ac5fc9f021da17a2
f626049cb59c4ef2997e8f22a2abd6ee
RX(theta₁₁)
46844216c28942a1ac5fc9f021da17a2--f626049cb59c4ef2997e8f22a2abd6ee
495cd65d12ea41fc942e1a4b12239e0a
X
f626049cb59c4ef2997e8f22a2abd6ee--495cd65d12ea41fc942e1a4b12239e0a
495cd65d12ea41fc942e1a4b12239e0a--165a4e83d32f44eea431c90444f648f9
dd7676c94e264bdeaf79c31e3e7a3dd2
495cd65d12ea41fc942e1a4b12239e0a--dd7676c94e264bdeaf79c31e3e7a3dd2
b1bcb9f1d6434162a8b126f1bc587b5a
RX(theta₁₅)
dd7676c94e264bdeaf79c31e3e7a3dd2--b1bcb9f1d6434162a8b126f1bc587b5a
6ade3575c1e540c29764d1d6b2f33059
RY(theta₁₉)
b1bcb9f1d6434162a8b126f1bc587b5a--6ade3575c1e540c29764d1d6b2f33059
f86f9d11b8674c6a9cf5263b18e0b07c
RX(theta₂₃)
6ade3575c1e540c29764d1d6b2f33059--f86f9d11b8674c6a9cf5263b18e0b07c
cbabd532a26948a589568f5005f7c65a
X
f86f9d11b8674c6a9cf5263b18e0b07c--cbabd532a26948a589568f5005f7c65a
cbabd532a26948a589568f5005f7c65a--7f55a730e1304adca41b62a9bfce6371
2f1b558ff6d541149463a63499a49258
cbabd532a26948a589568f5005f7c65a--2f1b558ff6d541149463a63499a49258
2f1b558ff6d541149463a63499a49258--ff452fe4b116431d96be659735625d91
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_93e64d5f3f0547bd9f185a6a9d65c2a5
Obs.
cluster_6554d6e40725452faa006f4cc1a2f1df
cluster_b0fee09461404f4b866c879fedbb5516
HEA
971d26ab9e224f6ab0691fdd07e146ec
0
81005017414e46149578f61547bd3533
RX(theta₀)
971d26ab9e224f6ab0691fdd07e146ec--81005017414e46149578f61547bd3533
eb10a74dcb2243f58d644dae73f835dd
1
612b0508e7824eaf9e4f9e0a7f34ace4
RY(theta₃)
81005017414e46149578f61547bd3533--612b0508e7824eaf9e4f9e0a7f34ace4
eff56875bce5434dac33ac612a3c0699
RX(theta₆)
612b0508e7824eaf9e4f9e0a7f34ace4--eff56875bce5434dac33ac612a3c0699
fafc475fec694d6c86020b36dbb0210f
eff56875bce5434dac33ac612a3c0699--fafc475fec694d6c86020b36dbb0210f
68e43d5d7ae64d508f8b7ce8fff2704c
fafc475fec694d6c86020b36dbb0210f--68e43d5d7ae64d508f8b7ce8fff2704c
8f73584883594a519f531cb37549e6e5
RX(theta₉)
68e43d5d7ae64d508f8b7ce8fff2704c--8f73584883594a519f531cb37549e6e5
929a6a1c13bf4b8eb139cb59ce0f6c4a
RY(theta₁₂)
8f73584883594a519f531cb37549e6e5--929a6a1c13bf4b8eb139cb59ce0f6c4a
778df88fd56446ab8a2428845bc074af
RX(theta₁₅)
929a6a1c13bf4b8eb139cb59ce0f6c4a--778df88fd56446ab8a2428845bc074af
924087b398514110a5ad021762ba0119
778df88fd56446ab8a2428845bc074af--924087b398514110a5ad021762ba0119
f9aaf78e01e640839e972c9d16a5e04b
924087b398514110a5ad021762ba0119--f9aaf78e01e640839e972c9d16a5e04b
9a37d758d2a24194b695e688c4f74e5d
f9aaf78e01e640839e972c9d16a5e04b--9a37d758d2a24194b695e688c4f74e5d
ac56b9b4d28c44a18f7f23ffe56491bc
9a37d758d2a24194b695e688c4f74e5d--ac56b9b4d28c44a18f7f23ffe56491bc
912548ab2f33485caa446493bf512623
130ebefdd19a4d8fb3b96960a7a36af7
RX(theta₁)
eb10a74dcb2243f58d644dae73f835dd--130ebefdd19a4d8fb3b96960a7a36af7
2419debe4e0442b4ae288b96044cebb5
2
587b5ced8ffb49a8acd27f47e1415359
RY(theta₄)
130ebefdd19a4d8fb3b96960a7a36af7--587b5ced8ffb49a8acd27f47e1415359
72ecb58d09d642fabfade3b761e7504c
RX(theta₇)
587b5ced8ffb49a8acd27f47e1415359--72ecb58d09d642fabfade3b761e7504c
32c2e6cb1d2b46ffa58e6d6d690b03b9
X
72ecb58d09d642fabfade3b761e7504c--32c2e6cb1d2b46ffa58e6d6d690b03b9
32c2e6cb1d2b46ffa58e6d6d690b03b9--fafc475fec694d6c86020b36dbb0210f
4bea2e5736564f72a5b6657310ffdecc
32c2e6cb1d2b46ffa58e6d6d690b03b9--4bea2e5736564f72a5b6657310ffdecc
3f6ffcd8c769493bbc05d37a1a8282ad
RX(theta₁₀)
4bea2e5736564f72a5b6657310ffdecc--3f6ffcd8c769493bbc05d37a1a8282ad
66f096b7041242939c263f2c7870765c
RY(theta₁₃)
3f6ffcd8c769493bbc05d37a1a8282ad--66f096b7041242939c263f2c7870765c
3be15f131f6d46778886a3fd08712cbe
RX(theta₁₆)
66f096b7041242939c263f2c7870765c--3be15f131f6d46778886a3fd08712cbe
365a1edfd8d6441980ba9249124a9829
X
3be15f131f6d46778886a3fd08712cbe--365a1edfd8d6441980ba9249124a9829
365a1edfd8d6441980ba9249124a9829--924087b398514110a5ad021762ba0119
de5e0bd8c0c64a5295e2f3b71931c126
365a1edfd8d6441980ba9249124a9829--de5e0bd8c0c64a5295e2f3b71931c126
cc291d23b06143ee82a0a9b358049095
AddBlock
de5e0bd8c0c64a5295e2f3b71931c126--cc291d23b06143ee82a0a9b358049095
cc291d23b06143ee82a0a9b358049095--912548ab2f33485caa446493bf512623
d454ff15822843d98020c6b01a482ba3
a23f638245b84641ae9c561e8ae5aacb
RX(theta₂)
2419debe4e0442b4ae288b96044cebb5--a23f638245b84641ae9c561e8ae5aacb
a848d7b310eb4e708cd313b3fde89bf9
RY(theta₅)
a23f638245b84641ae9c561e8ae5aacb--a848d7b310eb4e708cd313b3fde89bf9
6a132cdae47a430db05b1a76eb2b60b8
RX(theta₈)
a848d7b310eb4e708cd313b3fde89bf9--6a132cdae47a430db05b1a76eb2b60b8
2c1348c9e0fe4649bae9924fe1bd9edf
6a132cdae47a430db05b1a76eb2b60b8--2c1348c9e0fe4649bae9924fe1bd9edf
ea272e103d0c4041a3dfa1f27c30b8b8
X
2c1348c9e0fe4649bae9924fe1bd9edf--ea272e103d0c4041a3dfa1f27c30b8b8
ea272e103d0c4041a3dfa1f27c30b8b8--4bea2e5736564f72a5b6657310ffdecc
ed60abc303214b92949a2ab4c89187ad
RX(theta₁₁)
ea272e103d0c4041a3dfa1f27c30b8b8--ed60abc303214b92949a2ab4c89187ad
85d6d542cfde452ba5b588f659054666
RY(theta₁₄)
ed60abc303214b92949a2ab4c89187ad--85d6d542cfde452ba5b588f659054666
14670134bc0d4141b7b4102dc1662f0f
RX(theta₁₇)
85d6d542cfde452ba5b588f659054666--14670134bc0d4141b7b4102dc1662f0f
cabe68b9e7f04d9a99c2a5753fa26ccd
14670134bc0d4141b7b4102dc1662f0f--cabe68b9e7f04d9a99c2a5753fa26ccd
c7c1ed3d43744875ba972d8bb646bd9b
X
cabe68b9e7f04d9a99c2a5753fa26ccd--c7c1ed3d43744875ba972d8bb646bd9b
c7c1ed3d43744875ba972d8bb646bd9b--de5e0bd8c0c64a5295e2f3b71931c126
e932c0e7f10d4984ab39b925d0f6c2fb
c7c1ed3d43744875ba972d8bb646bd9b--e932c0e7f10d4984ab39b925d0f6c2fb
e932c0e7f10d4984ab39b925d0f6c2fb--d454ff15822843d98020c6b01a482ba3
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
58da8f87ce824c53975fb95ff99d2b5c
0
d568664f5c6b41d48f8db537895a95d2
58da8f87ce824c53975fb95ff99d2b5c--d568664f5c6b41d48f8db537895a95d2
1b37afeb7fda495893b200dfc244667f
1
65e2dc44c0bf43baabc008372ef50344
8fa45000a523446f9dc28735bc06d309
d568664f5c6b41d48f8db537895a95d2--8fa45000a523446f9dc28735bc06d309
110e941eeec542929ac14ec7594c217b
65e2dc44c0bf43baabc008372ef50344--110e941eeec542929ac14ec7594c217b
f40d8fdc52584fe8a1ef64eac270f9ff
03ee85d8ed66424ab927d1eded8975ee
110e941eeec542929ac14ec7594c217b--03ee85d8ed66424ab927d1eded8975ee
84afa397bd3b41a1b7cbf7ee5cd8c020
f40d8fdc52584fe8a1ef64eac270f9ff--84afa397bd3b41a1b7cbf7ee5cd8c020
48d9464c45a94f49abacff53229875b1
85dfc861ac0b447db3216de46763f33a
1b37afeb7fda495893b200dfc244667f--85dfc861ac0b447db3216de46763f33a
eaab49d0255f474e96117087f4a6df24
2
85dfc861ac0b447db3216de46763f33a--65e2dc44c0bf43baabc008372ef50344
2d45aa20926446a7b1f17ccff7d245f8
8fa45000a523446f9dc28735bc06d309--2d45aa20926446a7b1f17ccff7d245f8
32b599ef54724421a879742b27d8be42
2d45aa20926446a7b1f17ccff7d245f8--32b599ef54724421a879742b27d8be42
32b599ef54724421a879742b27d8be42--48d9464c45a94f49abacff53229875b1
14482b1a88254d518f0b2d2a60657a2c
17c78564746e445e9874774ac5774846
eaab49d0255f474e96117087f4a6df24--17c78564746e445e9874774ac5774846
90611d246bd44729aeeb46dbdabf8dd9
3
f75958b1370341f2bfbfab0d276226e7
17c78564746e445e9874774ac5774846--f75958b1370341f2bfbfab0d276226e7
901a3b2a8fc14498ae54a041c3bd6917
f75958b1370341f2bfbfab0d276226e7--901a3b2a8fc14498ae54a041c3bd6917
be9c9008f598405bb280044ef974bb08
901a3b2a8fc14498ae54a041c3bd6917--be9c9008f598405bb280044ef974bb08
be9c9008f598405bb280044ef974bb08--14482b1a88254d518f0b2d2a60657a2c
3912cba12ec44e55bebb40481a2b3aa1
f16de27c5c9b482baadc73eb8e1f427d
90611d246bd44729aeeb46dbdabf8dd9--f16de27c5c9b482baadc73eb8e1f427d
783dca924a0741038146c18e1817a85f
f16de27c5c9b482baadc73eb8e1f427d--783dca924a0741038146c18e1817a85f
5fda9191c93740dcbcc2d9fb2310f19a
783dca924a0741038146c18e1817a85f--5fda9191c93740dcbcc2d9fb2310f19a
5fda9191c93740dcbcc2d9fb2310f19a--f40d8fdc52584fe8a1ef64eac270f9ff
03ee85d8ed66424ab927d1eded8975ee--3912cba12ec44e55bebb40481a2b3aa1
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
6cf8e60e73514aa3a86826f05528c697
0
f4d425aeb96f449a890293be5a3c4fad
6cf8e60e73514aa3a86826f05528c697--f4d425aeb96f449a890293be5a3c4fad
056162a73021413e97a46cd569db841c
1
52375e6865fc410d8e692aeee9c991ba
f4d425aeb96f449a890293be5a3c4fad--52375e6865fc410d8e692aeee9c991ba
f4d01edbef7c4cec87440a99244e4fd8
52375e6865fc410d8e692aeee9c991ba--f4d01edbef7c4cec87440a99244e4fd8
bc88e71936224e74a8afb98c93e6f236
f4d01edbef7c4cec87440a99244e4fd8--bc88e71936224e74a8afb98c93e6f236
771ff7f76d0641f7bc82bb052eca0b74
69f8538ea5904a199fb5f048e4142dc2
PHASE(0.5)
056162a73021413e97a46cd569db841c--69f8538ea5904a199fb5f048e4142dc2
624ad448316d4a5a8c69e66f23ec2943
2
69f8538ea5904a199fb5f048e4142dc2--f4d425aeb96f449a890293be5a3c4fad
177c639820354a42b862c8a315d0db53
69f8538ea5904a199fb5f048e4142dc2--177c639820354a42b862c8a315d0db53
4ccc5194ffe54a4cbd5b99a31ef38103
177c639820354a42b862c8a315d0db53--4ccc5194ffe54a4cbd5b99a31ef38103
4ccc5194ffe54a4cbd5b99a31ef38103--771ff7f76d0641f7bc82bb052eca0b74
ab46e94150514a55b62ee61a00e2d5b3
7f64fc4806614a63a4698d32b47dd204
624ad448316d4a5a8c69e66f23ec2943--7f64fc4806614a63a4698d32b47dd204
1103c9bab74a4a378e5a1a34cc15b69f
3
f7ec3de7b3cb46479f8b7a09366f04ab
PHASE(0.5)
7f64fc4806614a63a4698d32b47dd204--f7ec3de7b3cb46479f8b7a09366f04ab
f7ec3de7b3cb46479f8b7a09366f04ab--52375e6865fc410d8e692aeee9c991ba
db275301c7954ab8a1735bea5907adaa
f7ec3de7b3cb46479f8b7a09366f04ab--db275301c7954ab8a1735bea5907adaa
db275301c7954ab8a1735bea5907adaa--ab46e94150514a55b62ee61a00e2d5b3
394b884adc6944778900f29114122e60
d8bd508a57914d22a39d70bf4ad2b999
1103c9bab74a4a378e5a1a34cc15b69f--d8bd508a57914d22a39d70bf4ad2b999
7213fb49e851445d8de82ceed5d3c159
d8bd508a57914d22a39d70bf4ad2b999--7213fb49e851445d8de82ceed5d3c159
94afad146ef143dc95213501fbcaea39
PHASE(0.5)
7213fb49e851445d8de82ceed5d3c159--94afad146ef143dc95213501fbcaea39
94afad146ef143dc95213501fbcaea39--f4d01edbef7c4cec87440a99244e4fd8
94afad146ef143dc95213501fbcaea39--394b884adc6944778900f29114122e60
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