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 405449752a2f49b6b051495b77318ad5 0 e47551292cfd499e8c7bdb79c7a13e36 X 405449752a2f49b6b051495b77318ad5--e47551292cfd499e8c7bdb79c7a13e36 b3d8d3e554c847c89c00edb9a474b86a 1 58684a299c7d44158491e3605b4bfa8b e47551292cfd499e8c7bdb79c7a13e36--58684a299c7d44158491e3605b4bfa8b 2b73774a34194899b399177b143eb77e e1fc4204b58d4880a71767b956b2e3f6 Y b3d8d3e554c847c89c00edb9a474b86a--e1fc4204b58d4880a71767b956b2e3f6 e1fc4204b58d4880a71767b956b2e3f6--2b73774a34194899b399177b143eb77e
from qadence import X, Y, chain
from qadence.draw import display

b = chain(X(0), Y(0))
%3 45c0b702014e42f78fd9a82b294d23ea 0 643d77b806854918917ea164ef54eb06 X 45c0b702014e42f78fd9a82b294d23ea--643d77b806854918917ea164ef54eb06 f6e46d7891c84608b9d61b6b80a839bb Y 643d77b806854918917ea164ef54eb06--f6e46d7891c84608b9d61b6b80a839bb 91f2f15c42ae44a3b6794467287b0dfd f6e46d7891c84608b9d61b6b80a839bb--91f2f15c42ae44a3b6794467287b0dfd
from qadence import X, Y, chain
from qadence.draw import display

b = chain(X(0), Y(1))
%3 2b3d8cf71ef0419fb83db586b33023d6 0 15a6161d35014393a9257c8de0abfb47 X 2b3d8cf71ef0419fb83db586b33023d6--15a6161d35014393a9257c8de0abfb47 e0a7045d3f5b48afad29c89130203c3a 1 516b70abe59c447aa801b6344fb4d396 15a6161d35014393a9257c8de0abfb47--516b70abe59c447aa801b6344fb4d396 a403cdb17a204d47aaf50bc18562492c 516b70abe59c447aa801b6344fb4d396--a403cdb17a204d47aaf50bc18562492c 99252f8c2ec846a79dbd9168bb02b448 9ee4410b93fd4c0581c5548370111f38 e0a7045d3f5b48afad29c89130203c3a--9ee4410b93fd4c0581c5548370111f38 f45799496f4943f5898e2a438b8c7a8d Y 9ee4410b93fd4c0581c5548370111f38--f45799496f4943f5898e2a438b8c7a8d f45799496f4943f5898e2a438b8c7a8d--99252f8c2ec846a79dbd9168bb02b448
from qadence import X, Y, add
from qadence.draw import display

b = add(X(0), Y(1), X(2))
%3 cluster_c864a73433c74d7eb2f26723ef54bba3 cd5b30b9bf904656b5750043aa6250b1 0 0b729a66e13c45398a59397d85a5b9e0 cd5b30b9bf904656b5750043aa6250b1--0b729a66e13c45398a59397d85a5b9e0 300e6354c28446c8ba983936a0f431f3 1 85f0c8d1d67c4b88ae5731486ebe2cd2 0b729a66e13c45398a59397d85a5b9e0--85f0c8d1d67c4b88ae5731486ebe2cd2 55aa6b2894a14caa92125433fb6c59c5 f5acd30376dc49b48069dfc3a6cab29c AddBlock 300e6354c28446c8ba983936a0f431f3--f5acd30376dc49b48069dfc3a6cab29c bd175cbc0a024d3b8c079fd146224e92 2 f5acd30376dc49b48069dfc3a6cab29c--55aa6b2894a14caa92125433fb6c59c5 a35f9c3caa454d4cbc5c2822d68e81ae 8165607f202f459e8e0560f05af47dbf bd175cbc0a024d3b8c079fd146224e92--8165607f202f459e8e0560f05af47dbf 8165607f202f459e8e0560f05af47dbf--a35f9c3caa454d4cbc5c2822d68e81ae
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_e0a8e92478134e0bbbe6ea1e0f0fa8be cluster_ddda519391df491d9f0613bf6cf2b75b rx 77ec45aed03147828949b4f3a663e123 0 37676fef2cf04912a22336e2cbde3a2f X 77ec45aed03147828949b4f3a663e123--37676fef2cf04912a22336e2cbde3a2f 1dd0cf8d20e8430580910e300aaa2515 1 1baa24217c8f42ac9d97854b2b8662d2 37676fef2cf04912a22336e2cbde3a2f--1baa24217c8f42ac9d97854b2b8662d2 4eb0dfa44a37458d9c1852b6f0ef4d05 1baa24217c8f42ac9d97854b2b8662d2--4eb0dfa44a37458d9c1852b6f0ef4d05 244297f9964b4a4cb5faa634d4ad7406 4eb0dfa44a37458d9c1852b6f0ef4d05--244297f9964b4a4cb5faa634d4ad7406 7a3dae85195349bb8b9aabea9d565f48 0c56f3bb283a4e6e995868f75ae09843 Y 1dd0cf8d20e8430580910e300aaa2515--0c56f3bb283a4e6e995868f75ae09843 a1a9b44f594a44b1bf80eea924f3f868 2 264ee916616c4a5bbc4921ccf0bbae5e 0c56f3bb283a4e6e995868f75ae09843--264ee916616c4a5bbc4921ccf0bbae5e 8abdd454613a43d89eddb4b8350f0752 HamEvo 264ee916616c4a5bbc4921ccf0bbae5e--8abdd454613a43d89eddb4b8350f0752 8abdd454613a43d89eddb4b8350f0752--7a3dae85195349bb8b9aabea9d565f48 ac6d5efb907b4fed97bd5907325ab56c 5f67a11bd3d64ab69e5554089e8aceeb RX(x) a1a9b44f594a44b1bf80eea924f3f868--5f67a11bd3d64ab69e5554089e8aceeb 984c9f3f73524567a664ddfd7c6b42f2 3 a30e444f5db244c692a9b9694b87bcd9 5f67a11bd3d64ab69e5554089e8aceeb--a30e444f5db244c692a9b9694b87bcd9 efb75892fd6e4874914a497e445cecc9 t = 10 a30e444f5db244c692a9b9694b87bcd9--efb75892fd6e4874914a497e445cecc9 efb75892fd6e4874914a497e445cecc9--ac6d5efb907b4fed97bd5907325ab56c bcb5947f853f468491279f5345b963d9 f6fac1a356374686a0a4db94b5a6b7cf RX(0.5) 984c9f3f73524567a664ddfd7c6b42f2--f6fac1a356374686a0a4db94b5a6b7cf e22b31af320945eaaa29296513b76254 X f6fac1a356374686a0a4db94b5a6b7cf--e22b31af320945eaaa29296513b76254 e22b31af320945eaaa29296513b76254--a30e444f5db244c692a9b9694b87bcd9 4fc059bcada747de84c20f88b7b3671f e22b31af320945eaaa29296513b76254--4fc059bcada747de84c20f88b7b3671f 4fc059bcada747de84c20f88b7b3671f--bcb5947f853f468491279f5345b963d9
from qadence import feature_map, hea, chain

block = chain(feature_map(4, reupload_scaling="Tower"), hea(4,2))
%3 cluster_8b36e051909f4b37957d115473c8082d HEA cluster_e868acf06c204ac896ed6e7faf63a924 Tower Fourier FM 098b9da27ef74c40bdd7bf8ac438ef1d 0 cfe74c01dc8943a1837e1b5aa0ab9f50 RX(1.0*phi) 098b9da27ef74c40bdd7bf8ac438ef1d--cfe74c01dc8943a1837e1b5aa0ab9f50 38e0b77787774d8f81b7ab1ed2ade294 1 2b2aad4d5c6d4d38acc214884c1d66bc RX(theta₀) cfe74c01dc8943a1837e1b5aa0ab9f50--2b2aad4d5c6d4d38acc214884c1d66bc 9af51280741e4a3783a1a01db85e45e1 RY(theta₄) 2b2aad4d5c6d4d38acc214884c1d66bc--9af51280741e4a3783a1a01db85e45e1 46c121ebc3354c4d82d7ce797b862a0b RX(theta₈) 9af51280741e4a3783a1a01db85e45e1--46c121ebc3354c4d82d7ce797b862a0b e9372f0e3e774174b016579e0d3fc52d 46c121ebc3354c4d82d7ce797b862a0b--e9372f0e3e774174b016579e0d3fc52d 9e3ca397911d4c7ca28ee892fee61ac5 e9372f0e3e774174b016579e0d3fc52d--9e3ca397911d4c7ca28ee892fee61ac5 57e9edbd5cce4a22b0091e2131b30f78 RX(theta₁₂) 9e3ca397911d4c7ca28ee892fee61ac5--57e9edbd5cce4a22b0091e2131b30f78 9d2d16c56e554108bd95ae1a770e052b RY(theta₁₆) 57e9edbd5cce4a22b0091e2131b30f78--9d2d16c56e554108bd95ae1a770e052b a5208d995eef4476b345ff5217b87bb0 RX(theta₂₀) 9d2d16c56e554108bd95ae1a770e052b--a5208d995eef4476b345ff5217b87bb0 9843c134537648ec87899e245d83f216 a5208d995eef4476b345ff5217b87bb0--9843c134537648ec87899e245d83f216 c153f5468e8d4c1983582a4987a3e4a9 9843c134537648ec87899e245d83f216--c153f5468e8d4c1983582a4987a3e4a9 13c85713655546c0a97448bb5c4238a4 c153f5468e8d4c1983582a4987a3e4a9--13c85713655546c0a97448bb5c4238a4 152ade8672d94418991ea2095cb19efb a2b6754e797642dab4cbff8985082aa0 RX(2.0*phi) 38e0b77787774d8f81b7ab1ed2ade294--a2b6754e797642dab4cbff8985082aa0 6fb8f0f1e5be4341a8b428c2115da6fd 2 2c164148b3734410b19fcb958cf92fee RX(theta₁) a2b6754e797642dab4cbff8985082aa0--2c164148b3734410b19fcb958cf92fee b9b99d4e9d144e36a536a48b09dc7b47 RY(theta₅) 2c164148b3734410b19fcb958cf92fee--b9b99d4e9d144e36a536a48b09dc7b47 58340bfb2cf940adab2458369965b237 RX(theta₉) b9b99d4e9d144e36a536a48b09dc7b47--58340bfb2cf940adab2458369965b237 42f10d332d114c74b3de7d6f052de7c1 X 58340bfb2cf940adab2458369965b237--42f10d332d114c74b3de7d6f052de7c1 42f10d332d114c74b3de7d6f052de7c1--e9372f0e3e774174b016579e0d3fc52d 25112d6d9d114ab68093c2e05044ed4b 42f10d332d114c74b3de7d6f052de7c1--25112d6d9d114ab68093c2e05044ed4b 9a875bfe229e4e7285934b9c68d4cc1e RX(theta₁₃) 25112d6d9d114ab68093c2e05044ed4b--9a875bfe229e4e7285934b9c68d4cc1e 2b362af9f26d4e2a927f2e76f8c06389 RY(theta₁₇) 9a875bfe229e4e7285934b9c68d4cc1e--2b362af9f26d4e2a927f2e76f8c06389 35b117a60f184ab480e0ec5bfb8308a2 RX(theta₂₁) 2b362af9f26d4e2a927f2e76f8c06389--35b117a60f184ab480e0ec5bfb8308a2 c9fa828a6e4a465e9d92f4a316ccdfc1 X 35b117a60f184ab480e0ec5bfb8308a2--c9fa828a6e4a465e9d92f4a316ccdfc1 c9fa828a6e4a465e9d92f4a316ccdfc1--9843c134537648ec87899e245d83f216 1a9a76fa4be447dd88077b6b0228c009 c9fa828a6e4a465e9d92f4a316ccdfc1--1a9a76fa4be447dd88077b6b0228c009 1a9a76fa4be447dd88077b6b0228c009--152ade8672d94418991ea2095cb19efb fc1abb02bb3e4550b55af1cdff0ade74 14c06a67094f4347935ab91109690d2a RX(3.0*phi) 6fb8f0f1e5be4341a8b428c2115da6fd--14c06a67094f4347935ab91109690d2a 33ca9ebf9d5f495c86a2dfdf24cab1fd 3 c97c7785a3094a96ad9feada0736d3dc RX(theta₂) 14c06a67094f4347935ab91109690d2a--c97c7785a3094a96ad9feada0736d3dc 295753bbdfbb481db6a149ab5eab6dd2 RY(theta₆) c97c7785a3094a96ad9feada0736d3dc--295753bbdfbb481db6a149ab5eab6dd2 334287701a4e494e9883481be22cfab7 RX(theta₁₀) 295753bbdfbb481db6a149ab5eab6dd2--334287701a4e494e9883481be22cfab7 44a3b8c2fb4a41f6b2062b8b60e9a592 334287701a4e494e9883481be22cfab7--44a3b8c2fb4a41f6b2062b8b60e9a592 a03a6152d64f4fe5a8b686c664e722bd X 44a3b8c2fb4a41f6b2062b8b60e9a592--a03a6152d64f4fe5a8b686c664e722bd a03a6152d64f4fe5a8b686c664e722bd--25112d6d9d114ab68093c2e05044ed4b 692ab8a775a04316b6235040ad12e5ee RX(theta₁₄) a03a6152d64f4fe5a8b686c664e722bd--692ab8a775a04316b6235040ad12e5ee 2630514f314249fea1935e490e052330 RY(theta₁₈) 692ab8a775a04316b6235040ad12e5ee--2630514f314249fea1935e490e052330 210e5c46453040e58c68ed2be95175f4 RX(theta₂₂) 2630514f314249fea1935e490e052330--210e5c46453040e58c68ed2be95175f4 f33573f38bc9453d93f736e1e06d882b 210e5c46453040e58c68ed2be95175f4--f33573f38bc9453d93f736e1e06d882b 55aa8e79246f4497ae3fcfa337c6bcfb X f33573f38bc9453d93f736e1e06d882b--55aa8e79246f4497ae3fcfa337c6bcfb 55aa8e79246f4497ae3fcfa337c6bcfb--1a9a76fa4be447dd88077b6b0228c009 55aa8e79246f4497ae3fcfa337c6bcfb--fc1abb02bb3e4550b55af1cdff0ade74 cb3c73c1c95d48259e6f77fe6d2ad320 1dd737045bc3494eacf2b6831a5b206d RX(4.0*phi) 33ca9ebf9d5f495c86a2dfdf24cab1fd--1dd737045bc3494eacf2b6831a5b206d 0d7fbf080e9a426b89ee23adfefb0017 RX(theta₃) 1dd737045bc3494eacf2b6831a5b206d--0d7fbf080e9a426b89ee23adfefb0017 a3af9a9a6efb4bc182fd6f7ac25b0835 RY(theta₇) 0d7fbf080e9a426b89ee23adfefb0017--a3af9a9a6efb4bc182fd6f7ac25b0835 a0fad22a2d2a419183bd5dfd232e2db7 RX(theta₁₁) a3af9a9a6efb4bc182fd6f7ac25b0835--a0fad22a2d2a419183bd5dfd232e2db7 cbe60b21eff9419d9a4d30d010161825 X a0fad22a2d2a419183bd5dfd232e2db7--cbe60b21eff9419d9a4d30d010161825 cbe60b21eff9419d9a4d30d010161825--44a3b8c2fb4a41f6b2062b8b60e9a592 6364e3104fdc4682806487b26cf9eb5e cbe60b21eff9419d9a4d30d010161825--6364e3104fdc4682806487b26cf9eb5e 2f68443189f743ffb97c70602ef425ac RX(theta₁₅) 6364e3104fdc4682806487b26cf9eb5e--2f68443189f743ffb97c70602ef425ac ae2fec013e5c450281422a461a4bd721 RY(theta₁₉) 2f68443189f743ffb97c70602ef425ac--ae2fec013e5c450281422a461a4bd721 dae5dafdec004935bbe296bfd1b36cac RX(theta₂₃) ae2fec013e5c450281422a461a4bd721--dae5dafdec004935bbe296bfd1b36cac fcc42abf34f844a793f0628d9456d009 X dae5dafdec004935bbe296bfd1b36cac--fcc42abf34f844a793f0628d9456d009 fcc42abf34f844a793f0628d9456d009--f33573f38bc9453d93f736e1e06d882b e151aa67741a43bbb134287034f85592 fcc42abf34f844a793f0628d9456d009--e151aa67741a43bbb134287034f85592 e151aa67741a43bbb134287034f85592--cb3c73c1c95d48259e6f77fe6d2ad320
from qadence import QuantumModel, QuantumCircuit, total_magnetization, hea

model = QuantumModel(QuantumCircuit(3, hea(3,2)), total_magnetization(3))
%3 cluster_d924379226a1466cb44f9637363262cf Obs. cluster_544443344eda4eb19f362acbf132bf72 cluster_29622fafb19a441fbcc4cc77541599be HEA 647848da1fbd4adebbad8cf22885aa02 0 07759f98913943fd8d4a9a8faa04f4e3 RX(theta₀) 647848da1fbd4adebbad8cf22885aa02--07759f98913943fd8d4a9a8faa04f4e3 3da4e530bf19410e80d2b0281df2dd72 1 a82c0879f20b46a080064d995f7f1ea4 RY(theta₃) 07759f98913943fd8d4a9a8faa04f4e3--a82c0879f20b46a080064d995f7f1ea4 3e536b0b8a3148cd86bda57236206864 RX(theta₆) a82c0879f20b46a080064d995f7f1ea4--3e536b0b8a3148cd86bda57236206864 1f3cefbdd34c42e5bfaf6a18471daace 3e536b0b8a3148cd86bda57236206864--1f3cefbdd34c42e5bfaf6a18471daace a39761617686459189aed9376a831119 1f3cefbdd34c42e5bfaf6a18471daace--a39761617686459189aed9376a831119 41cae16d9edc401f87d75acee76176cb RX(theta₉) a39761617686459189aed9376a831119--41cae16d9edc401f87d75acee76176cb abe0e7f7b7734da8ac159297b6343b1e RY(theta₁₂) 41cae16d9edc401f87d75acee76176cb--abe0e7f7b7734da8ac159297b6343b1e 90e66761f36040d1845a769476e3a241 RX(theta₁₅) abe0e7f7b7734da8ac159297b6343b1e--90e66761f36040d1845a769476e3a241 e293cc5b69d6483ab8df6f79991824d7 90e66761f36040d1845a769476e3a241--e293cc5b69d6483ab8df6f79991824d7 f148351444374be98457ec0465c049ec e293cc5b69d6483ab8df6f79991824d7--f148351444374be98457ec0465c049ec 6541e62ee7e64c47ba033034ed958f7b f148351444374be98457ec0465c049ec--6541e62ee7e64c47ba033034ed958f7b 2a1ee532c4d746728ccd0690b12506e7 6541e62ee7e64c47ba033034ed958f7b--2a1ee532c4d746728ccd0690b12506e7 9484234ba8594b8eb7dbe4ce271b26e7 cfc89c34fee144acaddc464dd8404c8d RX(theta₁) 3da4e530bf19410e80d2b0281df2dd72--cfc89c34fee144acaddc464dd8404c8d e762812bd8b44dd59849cc2f81128e2b 2 5c4ca5e9b9744cf89d8ac35e9bc5f039 RY(theta₄) cfc89c34fee144acaddc464dd8404c8d--5c4ca5e9b9744cf89d8ac35e9bc5f039 0153755cf1c845c2b57db8247b26dff4 RX(theta₇) 5c4ca5e9b9744cf89d8ac35e9bc5f039--0153755cf1c845c2b57db8247b26dff4 1ac83b84327c4cb7bd250add1f6b2927 X 0153755cf1c845c2b57db8247b26dff4--1ac83b84327c4cb7bd250add1f6b2927 1ac83b84327c4cb7bd250add1f6b2927--1f3cefbdd34c42e5bfaf6a18471daace af85fc3c1bdf4242bd0163c4ecc74e7f 1ac83b84327c4cb7bd250add1f6b2927--af85fc3c1bdf4242bd0163c4ecc74e7f 46537646893d4c6e9c209fe609b30aa1 RX(theta₁₀) af85fc3c1bdf4242bd0163c4ecc74e7f--46537646893d4c6e9c209fe609b30aa1 14bbff6a3ac24d60af4a0ce897b5c988 RY(theta₁₃) 46537646893d4c6e9c209fe609b30aa1--14bbff6a3ac24d60af4a0ce897b5c988 652b3b8291f3472298893e56dd9ab1ed RX(theta₁₆) 14bbff6a3ac24d60af4a0ce897b5c988--652b3b8291f3472298893e56dd9ab1ed 39893a99c3504312b162eb2115f35b15 X 652b3b8291f3472298893e56dd9ab1ed--39893a99c3504312b162eb2115f35b15 39893a99c3504312b162eb2115f35b15--e293cc5b69d6483ab8df6f79991824d7 087541f29914400fa5cd4bebd8772788 39893a99c3504312b162eb2115f35b15--087541f29914400fa5cd4bebd8772788 3c2b1ccc6efa46108b380f4e99bbcf89 AddBlock 087541f29914400fa5cd4bebd8772788--3c2b1ccc6efa46108b380f4e99bbcf89 3c2b1ccc6efa46108b380f4e99bbcf89--9484234ba8594b8eb7dbe4ce271b26e7 c8209f806a9d41778135922c464eeda6 46471ba083cf4693ae7c602085aa1907 RX(theta₂) e762812bd8b44dd59849cc2f81128e2b--46471ba083cf4693ae7c602085aa1907 bba057331f2e44219393910418c2ccc1 RY(theta₅) 46471ba083cf4693ae7c602085aa1907--bba057331f2e44219393910418c2ccc1 cac09ef906f843acbd37294e5d46fcc2 RX(theta₈) bba057331f2e44219393910418c2ccc1--cac09ef906f843acbd37294e5d46fcc2 66a9c5d83a45468883a5409397e02393 cac09ef906f843acbd37294e5d46fcc2--66a9c5d83a45468883a5409397e02393 da2dd8bfce554c00a6dd130fb8adf1a0 X 66a9c5d83a45468883a5409397e02393--da2dd8bfce554c00a6dd130fb8adf1a0 da2dd8bfce554c00a6dd130fb8adf1a0--af85fc3c1bdf4242bd0163c4ecc74e7f 481194a33cf74f1394e972893652fddb RX(theta₁₁) da2dd8bfce554c00a6dd130fb8adf1a0--481194a33cf74f1394e972893652fddb ef509862acba45148f57bc4d1df95b00 RY(theta₁₄) 481194a33cf74f1394e972893652fddb--ef509862acba45148f57bc4d1df95b00 c7f3787935cb4d8295c908af6f00b18f RX(theta₁₇) ef509862acba45148f57bc4d1df95b00--c7f3787935cb4d8295c908af6f00b18f 33727075f9c7421d9cf46e126075aed2 c7f3787935cb4d8295c908af6f00b18f--33727075f9c7421d9cf46e126075aed2 de433e8146cc403b9514b44bf40e381f X 33727075f9c7421d9cf46e126075aed2--de433e8146cc403b9514b44bf40e381f de433e8146cc403b9514b44bf40e381f--087541f29914400fa5cd4bebd8772788 51d7c561d75d4da48972b2093c6f746b de433e8146cc403b9514b44bf40e381f--51d7c561d75d4da48972b2093c6f746b 51d7c561d75d4da48972b2093c6f746b--c8209f806a9d41778135922c464eeda6
from qadence import *

b = chain(SWAP(0,1), SWAP(0,3))
%3 60ca5e5f99044df78dc139af8f8f9d97 0 14700764380e404eba4cad2a35e31fa6 60ca5e5f99044df78dc139af8f8f9d97--14700764380e404eba4cad2a35e31fa6 6de63c1fe3a2429f8b76a28960cbee91 1 074ca3241c3d41f4a453e862cbb72a2a 3a70ca50e0e84fd68041d9305300f02b 14700764380e404eba4cad2a35e31fa6--3a70ca50e0e84fd68041d9305300f02b 44a7d0fb96214541b9010564eb7b55fb 074ca3241c3d41f4a453e862cbb72a2a--44a7d0fb96214541b9010564eb7b55fb 5dfafe4fb19745feb31cb3a7a0fd8dfc 1c85170031624b00b590fd5368e38e09 44a7d0fb96214541b9010564eb7b55fb--1c85170031624b00b590fd5368e38e09 3b6fe5d3e72f4a08987a4671bd555a89 5dfafe4fb19745feb31cb3a7a0fd8dfc--3b6fe5d3e72f4a08987a4671bd555a89 aef9373f22734cdca50ad70a5096fac3 a61aa65229514ff1a0dc8cab7daafdce 6de63c1fe3a2429f8b76a28960cbee91--a61aa65229514ff1a0dc8cab7daafdce 15eaf1a7c48b479a86e59c043361d262 2 a61aa65229514ff1a0dc8cab7daafdce--074ca3241c3d41f4a453e862cbb72a2a 0fc7c6fb2548426bb0866ce814620e2d 3a70ca50e0e84fd68041d9305300f02b--0fc7c6fb2548426bb0866ce814620e2d c9ece38effb2416eacc19d8b77447f14 0fc7c6fb2548426bb0866ce814620e2d--c9ece38effb2416eacc19d8b77447f14 c9ece38effb2416eacc19d8b77447f14--aef9373f22734cdca50ad70a5096fac3 69d9d8d0726a4dc8a63a086f72e9e0af 696c8d042aec49e39615d948d1b908af 15eaf1a7c48b479a86e59c043361d262--696c8d042aec49e39615d948d1b908af 89e9a33a151b411998cd7286a2538d12 3 2f11b08936184d80b63faa63f90b4879 696c8d042aec49e39615d948d1b908af--2f11b08936184d80b63faa63f90b4879 40e4b83883144f58a303570a248d58f4 2f11b08936184d80b63faa63f90b4879--40e4b83883144f58a303570a248d58f4 262ab57458124e91951fde3e2c276f3b 40e4b83883144f58a303570a248d58f4--262ab57458124e91951fde3e2c276f3b 262ab57458124e91951fde3e2c276f3b--69d9d8d0726a4dc8a63a086f72e9e0af b68c838bf2ca4f9981fdb1c403d3b8fc e46988e05ada47f3aeabcedfe40a66b5 89e9a33a151b411998cd7286a2538d12--e46988e05ada47f3aeabcedfe40a66b5 6d49565ace5a450da2e313b51bebee98 e46988e05ada47f3aeabcedfe40a66b5--6d49565ace5a450da2e313b51bebee98 07e457477fb64b5c90067bd328f4ab08 6d49565ace5a450da2e313b51bebee98--07e457477fb64b5c90067bd328f4ab08 07e457477fb64b5c90067bd328f4ab08--5dfafe4fb19745feb31cb3a7a0fd8dfc 1c85170031624b00b590fd5368e38e09--b68c838bf2ca4f9981fdb1c403d3b8fc
from qadence import *

b = chain(CPHASE(0, 1, 0.5), CPHASE(0, 2, 0.5), CPHASE(0, 3, 0.5))
%3 6dc4a5f639e748f6bb793fc6f19fc87f 0 e437715bc45e4c288cf7068509845427 6dc4a5f639e748f6bb793fc6f19fc87f--e437715bc45e4c288cf7068509845427 1cb69f447f8b4e088dc99ff18d8da6e0 1 6fa2c39356b0499d91ce28807b48c66e e437715bc45e4c288cf7068509845427--6fa2c39356b0499d91ce28807b48c66e e7a7b81c4c9244bd922664c1d5ce9bf1 6fa2c39356b0499d91ce28807b48c66e--e7a7b81c4c9244bd922664c1d5ce9bf1 310ab850f99c4171b6008b8859a8c85f e7a7b81c4c9244bd922664c1d5ce9bf1--310ab850f99c4171b6008b8859a8c85f 45c436fa5e4d4e22bc4244f51e9b7948 0ab9ac10df884f1798d8b026eb69cd20 PHASE(0.5) 1cb69f447f8b4e088dc99ff18d8da6e0--0ab9ac10df884f1798d8b026eb69cd20 b7924ff4a6f742e9ba0eef6bd73debf3 2 0ab9ac10df884f1798d8b026eb69cd20--e437715bc45e4c288cf7068509845427 930ccb5222c445fe98c541cdb95660b6 0ab9ac10df884f1798d8b026eb69cd20--930ccb5222c445fe98c541cdb95660b6 779934b95ccf439fb18dc7faac3e1b38 930ccb5222c445fe98c541cdb95660b6--779934b95ccf439fb18dc7faac3e1b38 779934b95ccf439fb18dc7faac3e1b38--45c436fa5e4d4e22bc4244f51e9b7948 4ac18d7469c14b9a99ccb3f414280a2e f6f980d1062e455184d33fa4ee96bac8 b7924ff4a6f742e9ba0eef6bd73debf3--f6f980d1062e455184d33fa4ee96bac8 511dab1664a942e8bfbe46b659208714 3 e9e97c6f9b934449aa930e8a55ae3cf3 PHASE(0.5) f6f980d1062e455184d33fa4ee96bac8--e9e97c6f9b934449aa930e8a55ae3cf3 e9e97c6f9b934449aa930e8a55ae3cf3--6fa2c39356b0499d91ce28807b48c66e a793d03819d04d4e8483c6d4b42bc467 e9e97c6f9b934449aa930e8a55ae3cf3--a793d03819d04d4e8483c6d4b42bc467 a793d03819d04d4e8483c6d4b42bc467--4ac18d7469c14b9a99ccb3f414280a2e e77df965b0f04df2b8192131dd630ed5 d9abe35574834195ba3b6918bb6fbb23 511dab1664a942e8bfbe46b659208714--d9abe35574834195ba3b6918bb6fbb23 f469917236954271943ca2cc291c25ff d9abe35574834195ba3b6918bb6fbb23--f469917236954271943ca2cc291c25ff 3ec60057c0f44ac9822c7b080f2c8456 PHASE(0.5) f469917236954271943ca2cc291c25ff--3ec60057c0f44ac9822c7b080f2c8456 3ec60057c0f44ac9822c7b080f2c8456--e7a7b81c4c9244bd922664c1d5ce9bf1 3ec60057c0f44ac9822c7b080f2c8456--e77df965b0f04df2b8192131dd630ed5

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