Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Composing graphs loses grounds? #177

Closed
semiclassical opened this issue Nov 4, 2023 · 1 comment · Fixed by #178
Closed

Composing graphs loses grounds? #177

semiclassical opened this issue Nov 4, 2023 · 1 comment · Fixed by #178

Comments

@semiclassical
Copy link

To represent a one-qubit Z-measurement, I create a green phaseless spider with one input / one output and set it as a ground. At first glance, PyZX can handle this just fine:

c=zx.Circuit(1)
c.add_gate("ZPhase",0,phase=0)
g=c.to_graph()
g.set_ground(1)
zx.draw(g)
measurement

However, if I compose this graph with itself (zx.draw(g*g) then the second spider is no longer a ground:

measurement2

I've verified this as well for larger examples where the two graphs are different:

q=5;

c1=zx.Circuit(q)
for i in range(0,q-1,2):
    c1.add_gate("CNOT",i,i+1)
g1=c1.to_graph()
g1.auto_detect_io()

g2=zx.generate.identity(q)
for i in range(q):
    g2.set_type(2*i+1,1)
    g2.set_ground(2*i+1)
    v = g2.add_vertex(qubit=i,row=2)
    g2.add_edge(g2.edge(v,2*i+1),edgetype=zx.EdgeType.SIMPLE)
g2.auto_detect_io()
bad grounds
@ABorgna
Copy link
Contributor

ABorgna commented Nov 4, 2023

Can you try #178 ? That should fix it.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants