TeamGraphix / graphix

measurement-based quantum computing (MBQC) compiler and simulator
https://graphix.readthedocs.io
Apache License 2.0
55 stars 20 forks source link

bugfix gflow visualization #107

Closed d1ssk closed 6 months ago

d1ssk commented 6 months ago

Before submitting, please check the following:

Then, please fill in below:

Context (if applicable): Singular matrix error occured with visualisation tool when drawing graph with gflow. (#97 )

Description of the change: The direct cause of the error was in the get_figsize() method, which returned 0 height for pattern without input_nodes. Fixed that part and modified some detailed drawing methods for better gflow visualization.

Related issue:

97

also see that checks (github actions) pass. If lint check keeps failing, try installing black==22.8.0 as behavior seems to vary across versions.

d1ssk commented 6 months ago

As a example, these are visualizations of QNN pattern after Pauli measurements. The first one was generated by pattern.draw_graph() and the second one by pattern.draw_graph(node_distance=(1.2, 1.6)) to broaden node distances for better visualization.

スクリーンショット 2023-12-15 21 18 12 スクリーンショット 2023-12-15 21 18 03
shinich1 commented 6 months ago

@d1ssk if you have time - can you add type hints to visualization.py? I think it's time to start adding them part by part..

d1ssk commented 6 months ago

It seems that python<=3.8 and python>=3.9 have different ways of adding type hints. (Either include the typing module or use the built-in type hints class). Currently, graphix requirements are >=3.8,<3.12, so we need to decide which one we should use and make it consistent across the library. This time, I'm merging this PR without adding them.

pafloxy commented 5 months ago

I am not sure if this is the right place to ask this, but sometimes(or maybe always) there are edges with double arrows are showinf up in the plots which I am not sure how to interpret :/. Like if there are the elements from the correction-set then the arrows should have single heads no ?


For example image

here is a pettern where the correction sets are as follows : [{2: {1}, 3: {0, 1}, 4: {1, 3}}]

all vertices measured in XY, {0,1} are the outputs and {4,2} the inputs


Can you point out wht am I doing wrong ?

I instantiated graphix.vizualisation.GraphVisualizer on the adjacenecy matrix [[0, 0, 1, 1, 0], [0, 0, 1, 0, 0], [1, 1, 0, 0, 1], [1, 0, 0, 0, 1], [0, 0, 1, 1, 0]] i,e image

and the information about the input an the outputs. and used classmethod visualize_w_gflow() to generate the plot.

d1ssk commented 5 months ago

@pafloxy I have investigated this issue and found a basic logic error in the visualization method that had not been revealed until now. I will commit the change to fix this in PR #113. Thank you for pointing it out!

pafloxy commented 5 months ago

Ahn okay. glad to be of help ;). But can you maybe hint me at the problem ? So that I can bypass it somehow for my own tasks for a while before you fix it in the mentioned PR.

d1ssk commented 5 months ago

Sure. The problem had lain in the section where the edges to be drawn are collected, lines 547 and 548 of visualization.py. You can bypass this by modifying this part according to the latest commit in PR #113.